3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hinted(array $a, StdClass $b): int { return count($a); } function unhinted($a, $b) { return count($a); } $max = 10000000; $a = array(1,2,3,4); $b = new StdClass(); $b->foo = "bar"; // run unhinted test first to cause any possible cold startup effects to hit it more to make this as fair as possible for hinted code $start = microtime(true); for ($i=0; $i<$max; $i++) $rv = unhinted($a, $b); $elapsed_unhinted = microtime(true) - $start; printf("unhinted: Elapsed %.2f seconds\n", $elapsed_unhinted); $start = microtime(true); for ($i=0; $i<$max; $i++) $rv = hinted($a, $b); $elapsed_hinted = microtime(true) - $start; printf("hinted: Elapsed %.2f seconds\n", $elapsed_hinted); if ($elapsed_unhinted > 0) { $overhead = $elapsed_hinted / $elapsed_unhinted; if ($overhead <= 1.0) printf("No overhead for hinted signature, factor=%.2\n", $overhead); else printf("Type hinting causes %d %% overhead for small functions.\n", round(100*($overhead - 1.0))); }
Output for git.master
unhinted: Elapsed 0.14 seconds hinted: Elapsed 0.18 seconds Type hinting causes 25 % overhead for small functions.
Output for git.master_jit
unhinted: Elapsed 0.14 seconds hinted: Elapsed 0.40 seconds Type hinting causes 185 % overhead for small functions.
Output for rfc.property-hooks
unhinted: Elapsed 0.14 seconds hinted: Elapsed 0.17 seconds Type hinting causes 27 % overhead for small functions.

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:
77.86 ms | 408 KiB | 5 Q