PHP执行时间类
其实也就是通过
microtime
函数在前后个执行一下,计算时间差获取代码段的执行时间,测试效率
$runtime->stop();
echo $_b;
echo "页面执行时间: ".$runtime->spent()." 毫秒";
class runtime
{
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);
}
}
原文出自开源中国
- 上一篇: mysql的字符串函数
- 下一篇: PHP的mail函数