note 99524 deleted from function.microtime by danbrown
| From: | danbrown@php.net | Date: | Thu, 17 Jan 2013 15:42:12 +0000 |
| Subject: | note 99524 deleted from function.microtime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193174@lists.php.net to get a copy of this message | ||
Note Submitter: Paul
----
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';
?>