3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xrange($start, $end, $step = 1) { while ($start <= $end) { yield $start; $start += $step; } } function reduce(Generator $iterator, Callable $callback, $initial = null) { $result = $initial; foreach($iterator as $value) { $result = $callback($result, $value); } return $result; } $start = microtime(true); reduce(xrange(1, 140000), function($r, $v) {return $r + $v;}, 0); $byGen = microtime(true) - $start; $start =microtime(true); array_reduce(range(1,140000), function($r, $v) {return $r + $v;}, 0); $byNormal = microtime(true) - $start; $percent = ($byGen - $byNormal)*100/$byNormal; printf("Generator is %s than normal function %.2f%%.\n", ($byGen > $byNormal ? 'Slower' : 'Faster'), ($percent));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.00.0070.03625.12
7.1.120.0100.03624.68
7.1.110.0060.04224.34
7.1.100.0030.04124.27
7.1.90.0060.03623.96
7.1.80.0130.05323.97
7.1.70.0090.03723.10
7.1.60.0260.03041.34
7.1.50.0160.03941.17
7.1.40.0110.04840.47
7.1.30.0200.05040.54
7.1.20.0280.06040.58
7.1.10.0130.05622.57
7.1.00.0070.04922.61

preferences:
30.56 ms | 400 KiB | 5 Q