¡¾·±ÌåÖÐÎÄ¡¿
¡¾ÉèΪÊ×Ò³¡¿
¡¾¼ÓÈëÊղء¿
µ±Ç°Î»ÖãºPHP¼¼ÊõÊ×Ò³ >> PHPÓ¦Óà >> ¿´¹ýgoogleµÄËÑË÷Âð£¿ËÑË÷¹²»¨Á˶àÉÙʱ¼ä£¿ÕâÀïÓÐÒ»¸öÀà¿ÉÒÔͳ¼Æ½Å±¾Ö´ÐÐʱ¼äµÄ¡£

¿´¹ýgoogleµÄËÑË÷Âð£¿ËÑË÷¹²»¨Á˶àÉÙʱ¼ä£¿ÕâÀïÓÐÒ»¸öÀà¿ÉÒÔͳ¼Æ½Å±¾Ö´ÐÐʱ¼äµÄ¡£

2004-10-01 08:26:10  ×÷Õߣº  À´Ô´£º»¥ÁªÍø  ä¯ÀÀ´ÎÊý£º7  ÎÄ×Ö´óС£º¡¾´ó¡¿¡¾ÖС¿¡¾Ð¡¡¿
¼ò½é£º<?php // class PHP_timer¿ªÊ¼ class PHP_timer {     // ÓÃÀ´ÊÕ¼¯½Å±¾Ö´Ðйý³ÌÖеÄÐÅÏ¢     var $points = array();        &nbs...

// class PHP_timer¿ªÊ¼

class PHP_timer {

// ÓÃÀ´ÊÕ¼¯½Å±¾Ö´Ðйý³ÌÖеÄÐÅÏ¢

var $points = array();

// Ôڽű¾µÄ¿ªÊ¼´¦µ÷ÓÃÕâ¸öº¯Êý

function start() {

// Çë¿´ºóÃæµÄaddmarkerº¯Êý

$this->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 "

\n";

// µÚÒ»ÐÐÊÇûÓÐÔËÐÐʱ¼ä²îµÄ

echo "

\n";

echo "

";

echo "

";

echo "

\n";

echo "

\n";

// ´ÓÊý×éµÄÔªËØ1¿ªÊ¼Ñ­»·ÏÔʾ£¬0ÒѾ­ÔÚµÚÒ»ÐÐÏÔʾ¹ýÁË

for ($i = 1; $i < count($this->points);$i++) {

echo "

\n";

echo "

";

echo "

";

echo "

";

echo "

\n";

}

echo "

MarkerTimeDiff
".$this->points[0][1]." ".$this->points[0][0]." -
".$this->points[$i][1]." ".$this->points[$i][0]." ";

// ÏÔʾÉÏÏÂÁ½ÐеÄʱ¼ä²î

echo bcsub($this->points[$i][0],$this->points[$i-1][0],6);

echo "

";

}

// end function debug()

}

// end class PHP_timer

?>

ÔðÈα༭£ºadmin
±¾ÎÄÒýÓõØÖ·£º http://www.3pcode.com/php/2004/10/8128.htm
Ïà¹ØÎÄÕÂ