3v4l.org

run code in 300+ PHP versions simultaneously
<?php function merger($array1, $array2) { $result = array_merge($array1, $array2); } function spreader($array1, $array2) { $result = [...$array1, ...$array2]; } function uniter($array1, $array2) { $result = $array1 + $array2; } $array1 = []; $key = 'a'; for ($i = 0; $i < 500; ++$i) { $array1[++$key] = $i; } $array2 = []; for ($i = 500; $i < 1000; ++$i) { $array2[++$key] = $i; } $runs = 1000; // array_merge in loop $t0 = microtime(true); for ($i = 0; $i < $runs; ++$i) { merger($array1, $array2); } $tMerge = microtime(true); echo "merge: " . ($tMerge - $t0) . PHP_EOL; // array_merge with spread operator $t1 = microtime(true); for ($i = 0; $i < $runs; ++$i) { spreader($array1, $array2); } $tSpread = microtime(true); echo "spread: " . ($tSpread - $t1) . PHP_EOL; // union operator $t2 = microtime(true); for ($i = 0; $i < $runs; ++$i) { uniter($array1, $array2); } $tUnion = microtime(true); echo "union: " . ($tUnion - $t2);
Output for git.master_jit
merge: 0.0055010318756104 spread: 0.0087630748748779 union: 0.0061309337615967
Output for git.master
merge: 0.0046710968017578 spread: 0.0088348388671875 union: 0.0048420429229736
Output for rfc.property-hooks
merge: 0.0045599937438965 spread: 0.0087859630584717 union: 0.0050909519195557

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:
34.99 ms | 407 KiB | 5 Q