abstract class xDebug {
static private $labels = array();
static private $rndID = 1;
static function getSeqID() {
return self::$rndID++;
}
static function getTime() {
list($usec, $sec) = explode(" ", microtime());
return ((double)$usec + (double)$sec);
}
static function startLabel($label) {
self::$labels[$label] = array();
self::$labels[$label]['start'] = self::getTime();
return self::$labels[$label]['start'];
}
static function endLabel($label) {
self::$labels[$label]['end'] = self::getTime();
self::$labels[$label]['total'] = (self::$labels[$label]['end'] - self::$labels[$label]['start']);
return self::$labels[$label]['total'];
}
}
class test {
function t() {
return 1;
}
function __call($z, $zz) {
return 1;
}
}
function t() {
return 1;
}
$testclass = new test();
// __call
xDebug::startLabel('zz');
for ($i=0; $i < 1000; $i++) {
$cnt += $testclass->x();
}
echo xDebug::endLabel('zz'), '<br>';
//method
xDebug::startLabel('zz');
for ($i=0; $i < 1000; $i++) {
$cnt += $testclass->t();
}
echo xDebug::endLabel('zz'), '<br>';
// function
xDebug::startLabel('zz');
for ($i=0; $i < 1000; $i++) {
$cnt += t();
}
echo xDebug::endLabel('zz'), '<br>';
// math
xDebug::startLabel('zz');
for ($i=0; $i < 1000; $i++) {
$cnt+=1;
}
echo xDebug::endLabel('zz'), '<br>';