note 60463 deleted from function.microtime by tularis
| From: | tularis@php.net | Date: | Sun, 22 Jun 2008 12:12:19 +0000 |
| Subject: | note 60463 deleted from function.microtime by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140693@lists.php.net to get a copy of this message | ||
Note Submitter: ed [at] twixcoding [dot] com
----
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'
?>