3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar() { return ""; } } $ts = microtime(true); for ($i=1; $i<=10000; $i++) { $c = new Foo(); echo $c->bar(); unset ($c); } $tt = microtime(true); $t1 = $tt-$ts; unset($ts, $tt); echo "Variable Instantiation takes {$t1} seconds\n"; $ts = microtime(true); for ($i=1; $i<=10000; $i++) { echo (new Foo())->bar(); } $tt = microtime(true); $t2 = $tt-$ts; unset($ts, $tt); echo "Magic Instantiation takes {$t2} seconds\n"; echo "\n"; if ($t1 < $t2) { echo "Variable Instantion is faster by a factor of ".(($t2*100)/$t1)."\n"; } else { echo "Magic Instantion is faster by a factor of ".(($t1*100)/$t2)."\n"; }

preferences:
34.21 ms | 402 KiB | 5 Q