3v4l.org

run code in 300+ PHP versions simultaneously
<?php $benchFx = function (string $msg, \Closure $fx) { $times = []; for ($i = 0; $i < 100; $i++) { $t = microtime(true); $fx(); $t = microtime(true) - $t; $times[] = $t; } $bestTime = min($times); echo $msg . ': ' . round($bestTime * 1000, 2) . " ms\n"; }; $benchFx('array_shift', function () { $arr = range(1, 2_000); while (array_shift($arr)); }); $benchFx('array_pop', function () { $arr = range(1, 2_000); while (array_pop($arr)); });
Output for 8.3.8
array_shift: 2.33 ms array_pop: 0.03 ms
Output for 7.4.33
array_shift: 3.02 ms array_pop: 0.03 ms

preferences:
47.25 ms | 411 KiB | 5 Q