addmarker("Start");
}
// end function start()
// Ôڽű¾µÄ½áÊø´¦µ÷ÓÃÕâ¸öº¯Êý
function stop() {
// Çë¿´ºóÃæµÄaddmarkerº¯Êý
$this->addmarker("Stop");
}
// end function stop()
// Õâ¸öº¯ÊýÓÃÀ´Ôڽű¾Ö´ÐÐʱÔö¼ÓÒ»¸ö±ê¼Ç
// ÐèÒªÒ»¸öÓÃÀ´ÃèÊöµÄÃû×Ö
function addmarker($name) {
// µ÷Óà jointime() º¯Êý²¢½«microtime() µÄ·µ»ØÖµ´«µÝ¹ýÈ¥
$markertime = $this->jointime(microtime());
// $ae µÃµ½µ±Ç°Êý×éµÄ´óС£¬Ò²¾ÍÊǵ±Ç°µÄ²åÈëλÖÃ
// currently in the $points array
$ae = count($this->points);
// ÔÚÊý×éÖд洢timestamp ºÍ˵Ã÷
$this->points[$ae][0] = $markertime;
$this->points[$ae][1] = $name;
}
// end function addmarker()
// Õâ¸öº¯Êý»á´¦Àí´Ómicrotime() ·µ»ØµÄ×Ö´®
function jointime($mtime) {
// ·Ö½â×Ö´®
$timeparts = explode(" ",$mtime);
// Á¬½ÓÁ½¸ö×Ö´®£¬²¢È¥³ýСÊý²¿·ÖµÄ0
$finaltime = $timeparts[1].substr($timeparts[0],1);
// ·µ»ØÁ¬½ÓºóµÄ×Ö´®
return $finaltime;
}
// end function jointime()
// Õâ¸öº¯Êý¼òµ¥µÄÏÔʾ´Ó¿ªÊ¼µ½½áÊøËùÐèÒªµÄʱ¼ä
function showtime() {
echo bcsub($this->points[count($this->points)-1][0],$this->points[0][0],6);
}
// end function showtime()
// Õâ¸öº¯ÊýÏÔʾËùÓеÄÔڽű¾ÔËÐйý³ÌÖÐÊÕ¼¯µ½µÄÐÅÏ¢
function debug() {
echo "Script execution debug information:";
echo "
\n";
// Õâ¸ö±í¸ñÓÐ3ÁÐ Marker name, Timestamp, difference
echo "MarkerTimeDiff\n";
// µÚÒ»ÐÐÊÇûÓÐÔËÐÐʱ¼ä²îµÄ
echo "\n";
echo "".$this->points[0][1]."";
echo "".$this->points[0][0]."";
echo "-\n";
echo "\n";
// ´ÓÊý×éµÄÔªËØ1¿ªÊ¼Ñ»·ÏÔʾ£¬0ÒѾÔÚµÚÒ»ÐÐÏÔʾ¹ýÁË
for ($i = 1; $i points);$i++) {
echo "\n";
echo "".$this->points[$i][1]."";
echo "".$this->points[$i][0]."";
echo "";
// ÏÔʾÉÏÏÂÁ½ÐеÄʱ¼ä²î
echo bcsub($this->points[$i][0],$this->points[$i-1][0],6);
echo "";
echo "\n";
}
echo "
";
}
// end function debug()
}
// end class PHP_timer
?>

