From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- buildscripts/Benchmark/Iterate.php | 334 ++++++++++++++++++------------------- 1 file changed, 167 insertions(+), 167 deletions(-) (limited to 'buildscripts/Benchmark/Iterate.php') diff --git a/buildscripts/Benchmark/Iterate.php b/buildscripts/Benchmark/Iterate.php index acf1ec08..f09dcb76 100644 --- a/buildscripts/Benchmark/Iterate.php +++ b/buildscripts/Benchmark/Iterate.php @@ -1,167 +1,167 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to the New BSD license, That is bundled | -// | with this package in the file LICENSE, and is available through | -// | the world-wide-web at | -// | http://www.opensource.org/licenses/bsd-license.php | -// | If you did not receive a copy of the new BSDlicense and are unable | -// | to obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: Iterate.php,v 1.12 2006/02/17 16:29:44 toggg Exp $ -// - -require_once 'Benchmark/Timer.php'; - -/** - * Provides timing and profiling information. - * - * Example 1 - * - * - * '; - * } - * - * $benchmark->run(100, 'foo', 'test'); - * $result = $benchmark->get(); - * ?> - * - * - * Example 2 - * - * - * '; - * } - * } - * - * $benchmark->run(100, 'myclass::foo', 'test'); - * $result = $benchmark->get(); - * ?> - * - * - * Example 3 - * - * - * '; - * } - * } - * - * $o = new MyClass(); - * - * $benchmark->run(100, 'o->foo', 'test'); - * $result = $benchmark->get(); - * ?> - * - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Benchmarking - * @package Benchmark - */ -class Benchmark_Iterate extends Benchmark_Timer { - /** - * Benchmarks a function or method. - * - * @access public - */ - function run() { - $arguments = func_get_args(); - $iterations = array_shift($arguments); - $function_name = array_shift($arguments); - - if (strstr($function_name, '::')) { - $function_name = explode('::', $function_name); - $objectmethod = $function_name[1]; - } - - if (strstr($function_name, '->')) { - $function_name = explode('->', $function_name); - $objectname = $function_name[0]; - - $object = $GLOBALS[$objectname]; - $objectmethod = $function_name[1]; - - for ($i = 1; $i <= $iterations; $i++) { - $this->setMarker('start_' . $i); - call_user_func_array(array($object, $function_name[1]), $arguments); - $this->setMarker('end_' . $i); - } - - return(0); - } - - for ($i = 1; $i <= $iterations; $i++) { - $this->setMarker('start_' . $i); - call_user_func_array($function_name, $arguments); - $this->setMarker('end_' . $i); - } - } - - /** - * Returns benchmark result. - * - * $result[x ] = execution time of iteration x - * $result['mean' ] = mean execution time - * $result['iterations'] = number of iterations - * - * @return array - * @access public - */ - function get($simple_output = false) { - $result = array(); - $total = 0; - - $iterations = count($this->markers)/2; - - for ($i = 1; $i <= $iterations; $i++) { - $time = $this->timeElapsed('start_'.$i , 'end_'.$i); - - if (extension_loaded('bcmath')) { - $total = bcadd($total, $time, 6); - } else { - $total = $total + $time; - } - - if (!$simple_output) { - $result[$i] = $time; - } - } - - if (extension_loaded('bcmath')) { - $result['mean'] = bcdiv($total, $iterations, 6); - } else { - $result['mean'] = $total / $iterations; - } - - $result['iterations'] = $iterations; - - return $result; - } -} +. | +// +------------------------------------------------------------------------+ +// | This source file is subject to the New BSD license, That is bundled | +// | with this package in the file LICENSE, and is available through | +// | the world-wide-web at | +// | http://www.opensource.org/licenses/bsd-license.php | +// | If you did not receive a copy of the new BSDlicense and are unable | +// | to obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +------------------------------------------------------------------------+ +// +// $Id: Iterate.php,v 1.12 2006/02/17 16:29:44 toggg Exp $ +// + +require_once 'Benchmark/Timer.php'; + +/** + * Provides timing and profiling information. + * + * Example 1 + * + * + * '; + * } + * + * $benchmark->run(100, 'foo', 'test'); + * $result = $benchmark->get(); + * ?> + * + * + * Example 2 + * + * + * '; + * } + * } + * + * $benchmark->run(100, 'myclass::foo', 'test'); + * $result = $benchmark->get(); + * ?> + * + * + * Example 3 + * + * + * '; + * } + * } + * + * $o = new MyClass(); + * + * $benchmark->run(100, 'o->foo', 'test'); + * $result = $benchmark->get(); + * ?> + * + * + * @author Sebastian Bergmann + * @copyright Copyright © 2002-2005 Sebastian Bergmann + * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 + * @category Benchmarking + * @package Benchmark + */ +class Benchmark_Iterate extends Benchmark_Timer { + /** + * Benchmarks a function or method. + * + * @access public + */ + function run() { + $arguments = func_get_args(); + $iterations = array_shift($arguments); + $function_name = array_shift($arguments); + + if (strstr($function_name, '::')) { + $function_name = explode('::', $function_name); + $objectmethod = $function_name[1]; + } + + if (strstr($function_name, '->')) { + $function_name = explode('->', $function_name); + $objectname = $function_name[0]; + + $object = $GLOBALS[$objectname]; + $objectmethod = $function_name[1]; + + for ($i = 1; $i <= $iterations; $i++) { + $this->setMarker('start_' . $i); + call_user_func_array(array($object, $function_name[1]), $arguments); + $this->setMarker('end_' . $i); + } + + return(0); + } + + for ($i = 1; $i <= $iterations; $i++) { + $this->setMarker('start_' . $i); + call_user_func_array($function_name, $arguments); + $this->setMarker('end_' . $i); + } + } + + /** + * Returns benchmark result. + * + * $result[x ] = execution time of iteration x + * $result['mean' ] = mean execution time + * $result['iterations'] = number of iterations + * + * @return array + * @access public + */ + function get($simple_output = false) { + $result = array(); + $total = 0; + + $iterations = count($this->markers)/2; + + for ($i = 1; $i <= $iterations; $i++) { + $time = $this->timeElapsed('start_'.$i , 'end_'.$i); + + if (extension_loaded('bcmath')) { + $total = bcadd($total, $time, 6); + } else { + $total = $total + $time; + } + + if (!$simple_output) { + $result[$i] = $time; + } + } + + if (extension_loaded('bcmath')) { + $result['mean'] = bcdiv($total, $iterations, 6); + } else { + $result['mean'] = $total / $iterations; + } + + $result['iterations'] = $iterations; + + return $result; + } +} -- cgit v1.2.3