- microtime: documentation ( source)
- method_exists: documentation ( source)
<?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 />';