note 77340 added to function.microtime
| From: | Gero at osu1 dot php dot net | Date: | Fri, 24 Aug 2007 23:24:39 +0000 |
| Subject: | note 77340 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129772@lists.php.net to get a copy of this message | ||
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
----
Server IP: 217.13.201.10
Probable Submitter: 88.217.35.123
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/77340
Del: integrated -- https://master.php.net/note/delete/77340/integrated
Del: useless -- https://master.php.net/note/delete/77340/useless
Del: bad code -- https://master.php.net/note/delete/77340/bad+code
Del: spam -- https://master.php.net/note/delete/77340/spam
Del: non-english -- https://master.php.net/note/delete/77340/non-english
Del: in docs -- https://master.php.net/note/delete/77340/in+docs
Del: other reasons-- https://master.php.net/note/delete/77340
Reject -- https://master.php.net/note/reject/77340
Search -- https://master.php.net/manage/user-notes.php