- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.1 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0
Process exited with code 137.- Output for 7.0.0
- 1.2203509807587 1.1652750968933
<?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";