note 108255 added to function.microtime
| From: | thomas | Date: | Thu, 12 Apr 2012 02:45:29 +0000 |
| Subject: | note 108255 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187065@lists.php.net to get a copy of this message | ||
I have been getting negative values substracting a later microtime(true) call from an earlier
microtime(true) call on Windows with PHP 5.3.8
Produces negative values
------------------------------
for($i = 0; $i<100; $i++) {
$x = microtime(true);
//short calculation
$y = microtime(true);
echo ($y-$x) . "\n"; // <--- mostly negatives
}
Calling usleep(1) seems to work
---------------------------------------
for($i = 0; $i<100; $i++) {
$x = microtime(true);
//short calculation
usleep(1);
$y = microtime(true);
echo ($y-$x) . "\n"; // <--- fixed now
}
----
Server IP: 92.48.74.199
Probable Submitter: 88.96.89.222
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/108255
Del: integrated -- https://master.php.net/note/delete/108255/integrated
Del: useless -- https://master.php.net/note/delete/108255/useless
Del: bad code -- https://master.php.net/note/delete/108255/bad+code
Del: spam -- https://master.php.net/note/delete/108255/spam
Del: non-english -- https://master.php.net/note/delete/108255/non-english
Del: in docs -- https://master.php.net/note/delete/108255/in+docs
Del: other reasons-- https://master.php.net/note/delete/108255
Reject -- https://master.php.net/note/reject/108255
Search -- https://master.php.net/manage/user-notes.php