From: Sebastian Bergmann Date: Thu, 28 Sep 2000 11:45:13 +0000 (+0000) Subject: Removed profiling_information() in favour of a more generalized approach with get_pro... X-Git-Tag: php-4.0.3RC1~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39752c2ed0841588828fbeab64108cf9389f7439;p=php Removed profiling_information() in favour of a more generalized approach with get_profiling(). --- diff --git a/pear/Timer.php b/pear/Timer.php index 15877665ef..f5088ae26b 100644 --- a/pear/Timer.php +++ b/pear/Timer.php @@ -14,7 +14,6 @@ // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Sebastian Bergmann | -// | (based upon code by Allan Kent ) | // +----------------------------------------------------------------------+ // // $Id$ @@ -35,7 +34,7 @@ * $timer->set_marker( "Marker 1" ); * $timer->stop(); * - * $timer->profiling_information(); + * $profiling = $timer->get_profiling(); * * @author Sebastian Bergmann * @version 1.0 28/09/00 @@ -48,6 +47,7 @@ /** * Contains the markers + * * @var array * @access public */ @@ -59,6 +59,7 @@ /** * Set "Start" marker. + * * @brother stop() * @access public */ @@ -73,6 +74,7 @@ /** * Set "Stop" marker. + * * @brother start() * @access public */ @@ -87,6 +89,8 @@ /** * Set marker. + * + * @param string name of the marker to be set * @brother stop() * @access public */ @@ -102,6 +106,7 @@ /** * Returns the time elapsed betweens two markers. + * * @param string $start start marker, defaults to "Start" * @param string $end end marker, defaults to "Stop" * @return double $time_elapsed time elapsed between $start and $end @@ -114,22 +119,28 @@ } // }}} - // {{{ profiling_information() + // {{{ get_profiling() /** - * Prints profiling information. + * Returns profiling information. + * + * $profiling[ x ][ "name" ] = name of marker x + * $profiling[ x ][ "time" ] = time index of marker x + * $profiling[ x ][ "diff" ] = execution time from marker x-1 to this marker x + * $profiling[ x ][ "total" ] = total execution time up to marker x + * + * @return array $profiling * @access public */ - function profiling_information() + function get_profiling() { - print ""; + $i = 0; + $total = 0; + $result = array(); while( list( $marker, $time ) = each( $this->markers ) ) { - print ""; - print ""; - if( $marker == "Start" ) { $diff = "-"; @@ -137,15 +148,20 @@ else { - $diff = bcsub( $time, $temp, 6 ); + $diff = bcsub( $time, $temp, 6 ); + $total = bcadd( $total, $diff, 6 ); } - print ""; + $result[ $i ][ "name" ] = $marker; + $result[ $i ][ "time" ] = $time; + $result[ $i ][ "diff" ] = $diff; + $result[ $i ][ "total" ] = $total; $temp = $time; + $i++; } - print "
MarkerTimeDiff
" . $marker . "" . $time . "" . $diff . "
 Total:" . $this->time_elapsed() . "
"; + return $result; } // }}}