<?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($md5file, 0, 2);
$cd = substr($md5file, 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($md5file, 0, 2);
$cd = substr($md5file, 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";
preferences:
27.39 ms | 402 KiB | 5 Q