rendered paste body
class myfunclass {
public function __construct($config)
{
}
}
$class = 'myfunclass';
$config = array();
$total = 0;
$i = 0;
while ($i < 10000)
{
$i++;
$start = microtime(TRUE);
$reflection = new ReflectionClass($class);
$obj = $reflection->newInstanceArgs(array($config));
$total += microtime(TRUE) - $start;
}
echo "Reflection took " . $total / 10000 . " seconds on average\n";
$total = 0;
$i = 0;
while ($i < 10000)
{
$i++;
$start = microtime(TRUE);
$obj = new $class($config);
$total += microtime(TRUE) - $start;
}
echo 'new $class ' . $total / 10000 . " seconds on average";