note 99524 added to function.microtime
| From: | Paul at osu1 dot php dot net | Date: | Sat, 21 Aug 2010 18:44:28 +0000 |
| Subject: | note 99524 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171920@lists.php.net to get a copy of this message | ||
Something I noticed:
If you directly echo the time difference between start and the end you'll get a negative value
most of the time. If you calculate first this will work correctly:
<?php
//This will produce in negative value:
$start = microtime();
for($i=100;$i>0;$i--){
echo $i;
}
$end = microtime();
echo 'Took:'.$end-$start.' seconds';
?>
<?php
//This will produce a correct value
$start = microtime();
for($i=100;$i>0;$i--){
echo $i;
}
$end = microtime();
$parseTime = $end-$start;
echo 'Took:'.$parseTime.' seconds';
?>
----
Server IP: 69.147.83.197
Probable Submitter: 85.150.213.134
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/99524
Del: integrated -- https://master.php.net/note/delete/99524/integrated
Del: useless -- https://master.php.net/note/delete/99524/useless
Del: bad code -- https://master.php.net/note/delete/99524/bad+code
Del: spam -- https://master.php.net/note/delete/99524/spam
Del: non-english -- https://master.php.net/note/delete/99524/non-english
Del: in docs -- https://master.php.net/note/delete/99524/in+docs
Del: other reasons-- https://master.php.net/note/delete/99524
Reject -- https://master.php.net/note/reject/99524
Search -- https://master.php.net/manage/user-notes.php