note 63391 added to function.microtime
| From: | webmaster | Date: | Tue, 21 Mar 2006 23:01:58 +0000 |
| Subject: | note 63391 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-106185@lists.php.net to get a copy of this message | ||
Here is a small script I made so that I would not have to deal with vars. All you have to do is run
the function twice and the second time run, it will echo the runtime. If you place a number in the
last function "script_runtime(5)" it will round off the number to that decimal place.
<?php
function script_runtime ( $round = 20 ) {
//Check to see if the global is already set
if ( !empty( $GLOBALS['start_script_runtime'] ) ) {
//The global was set. So, get the current microtime and explode it into an
array.
list($msec, $sec) = explode(" ", microtime());
echo round(($sec + $msec) - $GLOBALS['start_script_runtime'], $round);
} else {
// The global was not set. Create it!
list($msec, $sec) = explode(" ", microtime());
$GLOBALS['start_script_runtime'] = $sec + $msec;
}
}
// Example:
script_runtime();
sleep(1);
script_runtime();
?>
----
Server IP: 216.194.113.175
Probable Submitter: 66.191.200.177
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- http://master.php.net/note/edit/63391
Del: integrated -- http://master.php.net/note/delete/63391/integrated
Del: useless -- http://master.php.net/note/delete/63391/useless
Del: bad code -- http://master.php.net/note/delete/63391/bad+code
Del: spam -- http://master.php.net/note/delete/63391/spam
Del: non-english -- http://master.php.net/note/delete/63391/non-english
Del: in docs -- http://master.php.net/note/delete/63391/in+docs
Del: other reasons-- http://master.php.net/note/delete/63391
Reject -- http://master.php.net/note/reject/63391
Search -- http://master.php.net/manage/user-notes.php