note 60463 added to function.microtime
| From: | ed | Date: | Sun, 08 Jan 2006 00:57:55 +0000 |
| Subject: | note 60463 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101375@lists.php.net to get a copy of this message | ||
I personally use the following class, created by myself, to record page creation time.
<?php
class Timer {
// Starts, Ends and Displays Page Creation Time
function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function starttime() {
$this->st = $this->getmicrotime();
}
function displaytime() {
$this->et = $this->getmicrotime();
return round(($this->et - $this->st), 3);
}
}
?>
Called by doing the following
<?php
$time = new Timer;
$time->starttime();
// The rest of your script
echo 'Script took '.$time->displaytime().' seconds to execute'
?>
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60463
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60463&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60463&report=yes
Search -- http://master.php.net/manage/user-notes.php