3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { } class Foo { private $bar; public function __construct(Bar $bar) { $this->bar = $bar; } } $bar = new Bar; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $reflect = new ReflectionClass('foo'); $constructor = $reflect->getConstructor(); } $t2 = microtime(true); echo 'getcons ' . ($t2-$t1) . '<br />'; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $constructor = method_exists('Foo', '__construct') ? new ReflectionMethod('Foo', '__construct') : null; } $t2 = microtime(true); echo 'rm: ' . ($t2-$t1) . '<br />';

preferences:
28.26 ms | 402 KiB | 5 Q