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