cvs: php4 /pear/Benchmark Iterate.php

From: Date: Wed, 25 Jul 2001 22:03:36 +0000
Subject: cvs: php4 /pear/Benchmark Iterate.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-342@lists.php.net to get a copy of this message
yavo Wed Jul 25 18:03:36 2001 EDT Modified files: /php4/pear/Benchmark Iterate.php Log: Added support for class::method and $object->method calls Index: php4/pear/Benchmark/Iterate.php diff -u php4/pear/Benchmark/Iterate.php:1.7 php4/pear/Benchmark/Iterate.php:1.8 --- php4/pear/Benchmark/Iterate.php:1.7 Mon Jul 23 05:57:52 2001 +++ php4/pear/Benchmark/Iterate.php Wed Jul 25 18:03:34 2001 @@ -16,7 +16,7 @@ // | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: Iterate.php,v 1.7 2001/07/23 09:57:52 sbergmann Exp $ +// $Id: Iterate.php,v 1.8 2001/07/25 22:03:34 yavo Exp $ // require_once 'Benchmark/Timer.php'; @@ -42,7 +42,7 @@ * $result = $benchmark->get(); * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> -* @version $Revision: 1.7 $ +* @version $Revision: 1.8 $ * @access public */ @@ -58,12 +58,29 @@ $iterations = array_shift($arguments); $function_name = array_shift($arguments); + + if(strstr($function_name, "::")){ + $function_name = explode("::", $function_name); + $objectmethod = $function_name[1]; + } + + // If we're calling a method on an object use call_user_method + if(strstr($function_name, "->")){ + $function_name = explode("->", $function_name); + $objectname = $function_name[0]; + global ${$objectname}; + $objectmethod = $function_name[1]; + for ($i = 1; $i <= $iterations; $i++) { + $this->setMarker('start_'.$i); + call_user_method_array($function_name[1], ${$objectname}, $arguments); + $this->setMarker('end_'.$i); + } + return(true); + } for ($i = 1; $i <= $iterations; $i++) { $this->setMarker('start_'.$i); - call_user_func_array($function_name, $arguments); - $this->setMarker('end_'.$i); } }

« previous php.pear.cvs (#342) next »