3v4l.org

run code in 300+ PHP versions simultaneously
#!/usr/bin/php <?php declare(strict_types=1); const ITERATIONS = 100000; $results = array(); for ($i = 0; $i < ITERATIONS; ++$i) { // heat up cpu (if it was powersaving-running-low-cus-nothing-was-happening, most modern cpus try to do it by default) } function array_is_list_post(array $array): bool { $i = 0; foreach ($array as $k => $v) { if ($k !== $i++) { return false; } } return true; } function array_is_list_pre(array $array): bool { $i = -1; foreach ($array as $k => $v) { ++$i; if ($k !== $i) { return false; } } return true; } $l1 = str_split(str_repeat("A", 300), 1); $t = microtime(true); for ($i = 0; $i < ITERATIONS; ++$i) { array_is_list_pre($l1); } $t = microtime(true) - $t; $results["pre"] = $t; $t = microtime(true); for ($i = 0; $i < ITERATIONS; ++$i) { array_is_list_post($l1); } $t = microtime(true) - $t; $results["post"] = $t; if ($results["pre"] === $results["post"]) { echo "it's a tie!"; } elseif ($results["pre"] < $results["post"]) { echo "pre is faster!"; } else { echo "post is faster!"; } echo "diff: " . abs(($results["pre"] - $results["post"])) . "\n"; var_dump($results); exit();
Output for git.master
pre is faster!diff: 0.068784236907959 array(2) { ["pre"]=> float(0.5784878730773926) ["post"]=> float(0.6472721099853516) }
Output for git.master_jit
pre is faster!diff: 0.013055086135864 array(2) { ["pre"]=> float(0.5878090858459473) ["post"]=> float(0.6008641719818115) }
Output for rfc.property-hooks
pre is faster!diff: 0.055403232574463 array(2) { ["pre"]=> float(0.6271319389343262) ["post"]=> float(0.6825351715087891) }

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:
40.92 ms | 401 KiB | 8 Q