3v4l.org

run code in 300+ PHP versions simultaneously
<?php // init all variables (so the first time isnt invalid because of variable creation) $a=array(); $b=null; $e=null; $l=100; $i=0; // do 100 times 2 microtime calls with nothing between it while($i++ < $l){ $b=microtime(true); $e=microtime(true); $a[] = $e - $b; } // calculate the average of these values (multiply by 1000 because I dont like the E-7) $an = (array_sum($a) / count($a))*1000; // re-init vars $i = 0; $a=array(); $b=null; $e=null; // do 100 times 2 microtime calls with 2 microtime calls between it while($i++ < $l){ $b=microtime(true); microtime(true); microtime(true); $e=microtime(true); $a[] = $e - $b; } // calculate average $am = (array_sum($a) / count($a))*1000; echo "Average empty: " . $an ."msec\n"; echo "Average filled: " . $am ."msec\n"; echo "Average 2 microtime calls: " . ($am - $an) . 'msec';

preferences:
37.71 ms | 402 KiB | 5 Q