note 77340 deleted from function.microtime by bjori
| From: | bjori@php.net | Date: | Sun, 26 Aug 2007 08:22:16 +0000 |
| Subject: | note 77340 deleted from function.microtime by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129791@lists.php.net to get a copy of this message | ||
Note Submitter: Gero
Reason: useless
----
This little debug class (works only in PHP5) needs only one line in your actual page code. (no, I
don't think it is very efficient, but I like the fact I only need to start the timer and it
stops itself by destructing, when the page is finished :-).
$timer = new Timer("Time elapsed: ", 4);
class Timer {
var $start_time;
var $stop_time;
var $total_time;
var $text;
var $digits;
public function __construct ($text, $digits) {
$this->start_time = microtime(true);
$this->text = $text;
$this->digits = $digits;
return;
}
public function __destruct () {
$this->stop_time = microtime(true);
$this->total_time = $this->stop_time - $this->start_time;
echo("<br /><br />" . $this->text .
round($this->total_time,$this->digits));
return;
}
} // end Timer