Re: Benchmark_Timer patch

From: Date: Wed, 23 Jan 2002 15:20:06 +0000
Subject: Re: Benchmark_Timer patch
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-4117@lists.php.net to get a copy of this message
ops....never trust Outlook Express =) 31,33c31 < * $timer = new Benchmark_Timer; < * < * $timer->start(); --- > * $timer =& new Benchmark_Timer; 35d32 < * $timer->stop(); 37d33 < * $profiling = $timer->getProfiling(); 44c40,42 < class Benchmark_Timer { --- > require_once('PEAR.php'); > > class Benchmark_Timer extends PEAR { 49c47 < * @access public --- > * @access private 53a52,99 > * Total time > * > * @var string > * @access public > */ > > var $total = 0; > > /** > * Constructor, starts profiling recording > * > * @access public > */ > function Benchmark_Timer() { > $this->PEAR(); > $this->start(); > } > > /** > * Destructor, stops profiling recording > * > * @access private > */ > function _Benchmark_Timer() { > $this->stop(); > echo($this->pretty_format()); > } > > /** > * Return formatted profiling information. > * > * @see getProfiling() > * @access public > */ > function pretty_format() { > $result = $this->getProfiling(); > $out = "<table border=1>\n"; > $out .= "<tr><td><b>key</b></td><td>time > index</td><td>ex time</td><td>%</td></tr>\n"; > foreach ($result as $k => $v) { > $perc = (($v['diff'] * 100) / $this->total); > $out .= "<tr><td>" . $v['name'] . > "</td><td>" . $v['time'] . "</td><td>" . $v['diff'] . "</td><td>" . number_format($perc, 2, '.', '') . "%</td></tr>\n"; > } > $out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>" . $this->total . "</td><td>100.00%</td></tr>\n"; > $out .= "</table>\n"; > return $out; > } > > /** 57c103 < * @access public --- > * @access private 67c113 < * @access public --- > * @access private 118,119c164,166 < if ($marker == 'Start') { < $diff = '-'; --- > if (extension_loaded('bcmath')) { > $diff = bcsub($time, $temp, 6); > $total = bcadd($total, $diff, 6); 121,127c168,169 < if (extension_loaded('bcmath')) { < $diff = bcsub($time, $temp, 6); < $total = bcadd($total, $diff, 6); < } else { < $diff = $time - $temp; < $total = $total + $diff; < } --- > $diff = $time - $temp; > $total = $total + $diff; 138c180,181 < --- > $result[0]['diff'] = '-'; > $this->total = $this->timeElapsed();

« previous php.pear.dev (#4117) next »