Source for file Iterate.php
Documentation is available at Iterate.php
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Copyright (c) 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
// +------------------------------------------------------------------------+
// | 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.
* require_once 'Benchmark/Iterate.php';
* $benchmark = new Benchmark_Iterate;
* function foo($string) {
* print $string . '<br>';
* $benchmark->run(100, 'foo', 'test');
* $result = $benchmark->get();
* require_once 'Benchmark/Iterate.php';
* $benchmark = new Benchmark_Iterate;
* function foo($string) {
* print $string . '<br>';
* $benchmark->run(100, 'myclass::foo', 'test');
* $result = $benchmark->get();
* require_once 'Benchmark/Iterate.php';
* $benchmark = new Benchmark_Iterate;
* function foo($string) {
* print $string . '<br>';
* $benchmark->run(100, 'o->foo', 'test');
* $result = $benchmark->get();
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright Copyright © 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
* Benchmarks a function or method.
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++ ) {
for ($i = 1; $i <= $iterations; $i++ ) {
* Returns benchmark result.
* $result[x ] = execution time of iteration x
* $result['mean' ] = mean execution time
* $result['iterations'] = number of iterations
function get($simple_output = false ) {
$iterations = count($this->markers)/2;
for ($i = 1; $i <= $iterations; $i++ ) {
$total = bcadd ($total, $time, 6 );
$result['mean'] = bcdiv ($total, $iterations, 6 );
$result['mean'] = $total / $iterations;
$result['iterations'] = $iterations;
Documentation generated on Mon, 11 Mar 2019 14:36:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|