3v4l.org

run code in 300+ PHP versions simultaneously
<?php function returnTime(callable $function, int $repeat = 50) { $tests = []; for ($i = 0; $i < $repeat; ++$i) { $startTime = microtime(true); $function(); $endTime = microtime(true); $tests[] = $endTime - $startTime; } // Representing the average return 1000 * array_sum($tests) / $repeat; } $array = range(0, 450000); unset($array[0]); echo "Duration of array_values: ", returnTime(function() use ($array) { $newArray = array_values($array); }); echo PHP_EOL; echo "Duration of splat-pack: " , returnTime(function() use ($array){ $newArray = [...$array]; });

preferences:
40.58 ms | 402 KiB | 5 Q