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]; });
Output for git.master
Duration of array_values: 1.2457513809204 Duration of splat-pack: 1.1143684387207
Output for git.master_jit
Duration of array_values: Fatal error: Out of memory (allocated 10489856 bytes) (tried to allocate 8388616 bytes) in /in/N8hNN on line 20 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for rfc.property-hooks
Duration of array_values: 1.8111276626587 Duration of splat-pack: 3.1850910186768

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
64.16 ms | 401 KiB | 8 Q