note 70877 added to function.microtime
| From: | sneskid at hotmail dot com | Date: | Thu, 02 Nov 2006 06:13:40 +0000 |
| Subject: | note 70877 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119310@lists.php.net to get a copy of this message | ||
I've noticed when running microtime() for the first time, there is a bit of a delay (v 5.1.4).
Try this:
<?php
function stuff() {
$t1 = microtime(true);
$t2 = microtime(true);
echo sprintf('%.6f', ($t2 - $t1) ) . "\r\n";
}
//microtime();
stuff();
stuff();
stuff();
?>
The first result will probably be a little higher.
I get:
0.000004
0.000001
0.000001
Then try calling microtime() just once before the stuff()s.
The first run will drop by a bit.
Don't forget sprint() can format your numbers.
----
Server IP: 66.163.161.117
Probable Submitter: 74.118.124.47
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/70877
Del: integrated -- https://master.php.net/note/delete/70877/integrated
Del: useless -- https://master.php.net/note/delete/70877/useless
Del: bad code -- https://master.php.net/note/delete/70877/bad+code
Del: spam -- https://master.php.net/note/delete/70877/spam
Del: non-english -- https://master.php.net/note/delete/70877/non-english
Del: in docs -- https://master.php.net/note/delete/70877/in+docs
Del: other reasons-- https://master.php.net/note/delete/70877
Reject -- https://master.php.net/note/reject/70877
Search -- https://master.php.net/manage/user-notes.php