note 104053 added to function.microtime
| From: | langpavelatphpskeletdotorg at osu1 dot php dot net | Date: | Thu, 19 May 2011 20:46:22 +0000 |
| Subject: | note 104053 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179890@lists.php.net to get a copy of this message | ||
I use this for measure duration of script execution. This function should be defined (and of couse
first call made) as soon as possible.
<?php
/**
* get execution time in seconds at current point of call in seconds
* @return float Execution time at this point of call
*/
function get_execution_time()
{
static $microtime_start = null;
if($microtime_start === null)
{
$microtime_start = microtime(true);
return 0.0;
}
return microtime(true) - $microtime_start;
}
get_execution_time();
?>
However it is true that result depends of gettimeofday() call. ([jamie at bishopston dot net] wrote
this & I can confirm)
If system time change, result of this function can be unpredictable (much greater or less than
zero).
----
Server IP: 69.147.83.197
Probable Submitter: 62.240.163.46
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/104053
Del: integrated -- https://master.php.net/note/delete/104053/integrated
Del: useless -- https://master.php.net/note/delete/104053/useless
Del: bad code -- https://master.php.net/note/delete/104053/bad+code
Del: spam -- https://master.php.net/note/delete/104053/spam
Del: non-english -- https://master.php.net/note/delete/104053/non-english
Del: in docs -- https://master.php.net/note/delete/104053/in+docs
Del: other reasons-- https://master.php.net/note/delete/104053
Reject -- https://master.php.net/note/reject/104053
Search -- https://master.php.net/manage/user-notes.php