PHP 计算页面执行时间
发布时间:2009-12-01 17:41:28,阅读人数:184
PHP: // 说明:PHP 计算页面执行时间 class timer function get_microtime() function start() function stop() function spent() } /* //你的代码开始 $a = 0; //你的代码结束 $timer->stop();
// 整理:http://icyboy.0fees.net
{
var $StartTime = 0;
var $StopTime = 0;
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
{
$this->StartTime = $this->get_microtime();
}
{
$this->StopTime = $this->get_microtime();
}
{
return round(($this->StopTime – $this->StartTime) * 1000, 1);
}
//例子
$timer = new timer;
$timer->start();
for($i=0; $i<1000000; $i++)
{
$a += $i;
}
echo “页面执行时间: “.$timer->spent().” 毫秒”;
*/
?>
我也要说两句
热门博文

