All pastes #632686 Raw Edit

Miscellany

public text v1 · immutable
#632686 ·published 2007-07-25 02:07 UTC
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";