3v4l.org

run code in 300+ PHP versions simultaneously
<? $count = 1000000; function t($a, $b) { return ($a + $b) * ($a - $b); } class test { public static function staticTest($a, $b) { return ($a + $b) * ($a - $b); } } $time = microtime(true); $i = 0; $a = 1; $b = 1; while ($i++ < $count) { $res = ($a + $b) * ($a - $b); $a = $a + 2; $b = $b + 1; } echo '$a = $a + 1: ', "\t\t\t", (microtime(true) - $time), PHP_EOL; $time = microtime(true); $i = 0; $a = 1; $b = 1; while ($i++ < $count) { $a = t($a, $b); $a = $a + 2; $b = $b + 1; } echo '$a = t($a): ', "\t\t\t", (microtime(true) - $time), PHP_EOL; $time = microtime(true); $i = 0; $a = 1; $b = 1; while ($i++ < $count) { test::staticTest($a, $b); $a = $a + 2; $b = $b + 1; } echo 'test::staticTest($a): ', "\t\t", (microtime(true) - $time), PHP_EOL;

preferences:
51.18 ms | 402 KiB | 5 Q