From: Chuck Hagenbuch Date: Thu, 28 Sep 2000 14:59:41 +0000 (+0000) Subject: move the timer class to Benchmark/Timer.php, and add it to Makefile.in so it X-Git-Tag: php-4.0.3RC1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a4e086d7a72fe842f7ce945e74d1abfde5e7a5c;p=php move the timer class to Benchmark/Timer.php, and add it to Makefile.in so it gets installed. --- diff --git a/pear/Makefile.in b/pear/Makefile.in index f39f2b1d79..b6cca32be1 100644 --- a/pear/Makefile.in +++ b/pear/Makefile.in @@ -10,6 +10,7 @@ include $(top_srcdir)/build/rules.mk peardir=$(PEAR_INSTALLDIR) PEAR_SUBDIRS = \ + Benchmark \ DB \ File \ HTML \ @@ -19,6 +20,7 @@ PEAR_SUBDIRS = \ XML PEAR_FILES = \ + Benchmark/Timer.php \ DB.php \ DB/common.php \ DB/ibase.php \ diff --git a/pear/Timer.php b/pear/Timer.php deleted file mode 100644 index f5088ae26b..0000000000 --- a/pear/Timer.php +++ /dev/null @@ -1,169 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - /** - * PEAR/Timer - * - * Purpose: - * - * Timing Script Execution, Generating Profiling Information - * - * Example: - * - * $timer = new Timer; - * - * $timer->start(); - * $timer->set_marker( "Marker 1" ); - * $timer->stop(); - * - * $profiling = $timer->get_profiling(); - * - * @author Sebastian Bergmann - * @version 1.0 28/09/00 - * @access public - */ - - class Timer - { - // {{{ properties - - /** - * Contains the markers - * - * @var array - * @access public - */ - - var $markers = array(); - - // }}} - // {{{ start() - - /** - * Set "Start" marker. - * - * @brother stop() - * @access public - */ - - function start() - { - $this->set_marker( "Start" ); - } - - // }}} - // {{{ stop() - - /** - * Set "Stop" marker. - * - * @brother start() - * @access public - */ - - function stop() - { - $this->set_marker( "Stop" ); - } - - // }}} - // {{{ set_marker() - - /** - * Set marker. - * - * @param string name of the marker to be set - * @brother stop() - * @access public - */ - - function set_marker( $name ) - { - $microtime = explode( " ", microtime() ); - $this->markers[ $name ] = $microtime[ 1 ] . substr( $microtime[ 0 ], 1 ); - } - - // }}} - // {{{ time_elapsed() - - /** - * 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 - * @access public - */ - - function time_elapsed( $start = "Start", $end = "Stop" ) - { - return bcsub( $this->markers[ $end ], $this->markers[ $start ], 6 ); - } - - // }}} - // {{{ get_profiling() - - /** - * 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 get_profiling() - { - $i = 0; - $total = 0; - $result = array(); - - while( list( $marker, $time ) = each( $this->markers ) ) - { - if( $marker == "Start" ) - { - $diff = "-"; - } - - else - { - $diff = bcsub( $time, $temp, 6 ); - $total = bcadd( $total, $diff, 6 ); - } - - $result[ $i ][ "name" ] = $marker; - $result[ $i ][ "time" ] = $time; - $result[ $i ][ "diff" ] = $diff; - $result[ $i ][ "total" ] = $total; - - $temp = $time; - $i++; - } - - return $result; - } - - // }}} - } -?>