3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); // The original function function a($i){$e=microtime(1)+$i;while(microtime(1)<$e);} // Use 'for' instead of 'while' function b($i){for($e=microtime(1)+$i;microtime(1)<$e;);} // Extract 'microtime' into a variable function c($i){for($f=microtime,$e=$f(1)+$i;$f(1)<$e;);} //var_dump(PHP_VERSION_ID); exit(); // PHP 7 only: initialize $f on its first use //if (70000 <= PHP_VERSION_ID) { // function d($i){for($e=($f=microtime)(1)+$i;$f(1)<$e;);} //} // Test $t0 = microtime(true); a(1); $ta = microtime(true); b(1); $tb = microtime(true); c(1); $tc = microtime(true); if (70000 <= PHP_VERSION_ID) { // d(1); } $td = microtime(true); printf("a(): %.6f\n", $ta-$t0); printf("b(): %.6f\n", $tb-$ta); printf("c(): %.6f\n", $tc-$tb); if (70000 <= PHP_VERSION_ID) { // printf("d(): %.6f\n", $td-$tc); } else { printf("d(): N/A\n"); }

preferences:
32.14 ms | 402 KiB | 5 Q