- microtime: documentation ( source)
<?php
class SomeObj {
public function doTest() {}
}
$someObj = new SomeObj;
class SomeClass {
public static function doTest() {;}
}
// bench static method
$starttime = microtime(true);
for ($i = 0; $i< 100000; $i++)
SomeClass::doTest($i);
echo "Static Time: " , (microtime(true)-$starttime) , " ms\n";
// bench object method
$starttime = microtime(true);
for ($i = 0; $i< 10*1000*1000; $i++)
$someObj->doTest($i);
echo "Object Time: " , (microtime(true)-$starttime) , " ms\n";