@ 2012-12-27T23:53:56Z <?php
function test1() {
$str = 'derp';
if ($str != 'files' && $str != 'something' && $str != 'Derrr') {
return;
}
return;
}
function test2() {
$str = 'derp';
switch ($str) {
case 'files':
case 'something':
case 'Derrr':
break;
default:
return;
}
return;
}
function runTest1() {
$start1 = microtime(1);
for ($i = 1; $i < 10000; $i++) {
test1();
}
$start1 -= microtime(1);
return $start1;
}
function runTest2() {
$start2 = microtime(1);
for ($i = 1; $i < 10000; $i++) {
test2();
}
$start2 -= microtime(1);
return $start2;
}
$tests2 = 0;
for($i = 0;$i<1000;$i++) {
$tests2 += runTests2();
}
$start2 = $tests2 / 1000;
$tests1 = 0;
for($i = 0;$i<1000;$i++) {
$tests1 += runTests2();
}
$start2 = $tests1 / 1000;
if ($start1 < $start2) {
$perc = 100-round(($start2 / $start1) * 100,2);
echo "Test1 is $perc"."% faster than Test2";
}
if ($start2 < $start1) {
$perc = 100-round(($start1 / $start2) * 100,2);
echo "Test2 is $perc"."% faster than Test1";
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.24 , 7.3.0 - 7.3.12 Fatal error: Uncaught Error: Call to undefined function runTests2() in /in/4gHtI:46
Stack trace:
#0 {main}
thrown in /in/4gHtI on line 46
Process exited with code 255 . Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.36 , 5.6.0 - 5.6.28 Fatal error: Call to undefined function runTests2() in /in/4gHtI on line 46
Process exited with code 255 . Output for 4.4.5 - 4.4.9 Fatal error: Call to undefined function: runtests2() in /in/4gHtI on line 46
Process exited with code 255 . Output for 4.3.2 - 4.3.11 , 4.4.0 - 4.4.4 Fatal error: Call to undefined function: runtests2() in /in/4gHtI on line 46
Process exited with code 255 . Output for 4.3.0 - 4.3.1 Fatal error: Call to undefined function: runtests2() in /in/4gHtI on line 46
preferences:dark mode live preview
143.83 ms | 401 KiB | 254 Q