<?php
/**
* 耗时测试函数
* 有误差,精度大概在0.01左右
*/
function
getRunTime()
{
list
($msec, $sec) = explode(
' '
, microtime());
return
(float)$sec+(float)$msec;
}
/*********************测试数据***********************/
header(
"Content-type:text/html; charset=utf-8"
);
$nowTime = getRunTime();
sleep(2);
//延迟2秒
echo
'本次执行耗时:'
.(getRunTime()-$nowTime).
' 秒'
;
//如果想获取程序执行时间有相关插件,xdebug
/****************************************************/
?>