3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! class foo { function doSomething($a) { return $a + 2; } } $start = microtime(true); $foo = new foo(); for ($i = 0; $i < 100000; $i++) { $foo->doSomething(1); } $end1 = (microtime(true) - $start); echo $end1 . PHP_EOL; $start = microtime(true); $foo = new foo(); $doSomething = new \reflectionMethod('foo', 'doSomething'); for ($i = 0; $i < 100000; $i++) { $doSomething->invoke($foo, 1); } $end2 = (microtime(true) - $start); echo $end2 . PHP_EOL; var_dump($end2 - $end1);

preferences:
33.47 ms | 402 KiB | 5 Q