当前位置:编程学习 > php >>

怎么计算一个程序的执行时间

function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec (float)$sec);
}

$time_start = getmicrotime();//开始计时, 放在程序头

for ($i=0; $i < 1000; $i ){
//do nothing, 1000 times
}

$time_end = getmicrotime();//结束计时, 放在尾部
$time = $time_end - $time_start;

echo "Did nothing in $time seconds";

补充:Php教程,常见问题 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,