博客更新:2010-09-02 17:18:01 - 解决部分用户访问www.wetuan.com打开企业邮箱的问题

PHP 计算页面执行时间

发布时间:2009-12-01 17:41:28,阅读人数:184

PHP:

// 说明:PHP 计算页面执行时间
// 整理:http://icyboy.0fees.net

class timer
{
var $StartTime = 0;
var $StopTime = 0;

function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}

function start()
{
$this->StartTime = $this->get_microtime();
}

function stop()
{
$this->StopTime = $this->get_microtime();
}

function spent()
{
return round(($this->StopTime – $this->StartTime) * 1000, 1);
}

}

/*
//例子
$timer = new timer;
$timer->start();

//你的代码开始

$a = 0;
for($i=0; $i<1000000; $i++)
{
$a += $i;
}

//你的代码结束

$timer->stop();
echo “页面执行时间: “.$timer->spent().” 毫秒”;
*/
?>

发布人:xシpeng

我也要说两句

  • 称呼:
  • 邮箱:
  • 主页:
  • 内容:

来自客户的声音

“网站整体风格符合我公司的新概念娱乐文化,中英文无缝切换模式体现了源于思想的技术能力和创新思想。我们很满意,期待再一次的合作!”

新影视娱乐文化传播
2009年5月1日