3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* How many times the code under test should run in each function */ define('LOOP',1000000); function f1() { $path = NULL; for($i=0; $i<LOOP; ++$i) { $md5 = md5(str_shuffle('asbfdgdg5y54yy5rh45g5ge5g5g')); $yy = date('y'); $ab = substr($md5, 0, 2); $cd = substr($md5, 2, 2); $path = 'some' . '/'; $path .= $yy . '/'; $path .= $ab . '/'; $path .= $cd . '/'; } } function f2() { $path = NULL; for($i=0; $i<LOOP; ++$i) { $md5 = md5(str_shuffle('asbfdgdg5y54yy5rh45g5ge5g5g')); $yy = date('y'); $ab = substr($md5, 0, 2); $cd = substr($md5, 2, 2); $path = sprintf('%s/%s/%s/%s', 'some', $yy, $ab, $cd); } } $start = microtime(true); f1(); $stop = microtime(true); $time1 = $stop - $start; $start = microtime(true); f2(); $stop = microtime(true); $time2 = $stop - $start; echo $time1 . "\t"; echo $time2 . "\n";
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.1 - 7.1.0

Process exited with code 137.
Output for 7.0.0
1.2203509807587 1.1652750968933