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]; });
based on SMs4H

Abusive script

This script was stopped while abusing our resources

Output for 7.4.12
Duration of array_values: 44.371747970581 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.11
Duration of array_values: 20.145397186279 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.10
Duration of array_values: 20.671572685242 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.9
Duration of array_values: 23.204317092896 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.8
Duration of array_values: 22.800283432007 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.7
Duration of array_values: 22.599430084229 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.6
Duration of array_values: 22.231225967407 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.5
Duration of array_values: 20.121531486511 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.4
Duration of array_values: 21.313028335571 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.3
Duration of array_values: 24.878735542297 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.2
Duration of array_values: 20.163249969482 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.1
Duration of array_values: 26.28719329834 Duration of splat-pack:
Process exited with code 137.
Output for 7.4.0
Duration of array_values: 21.063947677612 Duration of splat-pack:
Process exited with code 137.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.24
Parse error: syntax error, unexpected '...' (T_ELLIPSIS), expecting ']' in /in/N8hNN on line 26
Process exited with code 255.