管理员登陆

停止 继续 暂停 收听本文

php计算页面执行时间

在PHP网页的开头加入以下
<?
$time_start = getmicrotime(); 
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
?>

然后到最后加入以下代码

<?
$time_end = getmicrotime();
printf ("[页面执行时间: %.2f毫秒]\n\n",($time_end - $time_start)*1000);
?>

************** Other code *************

<?php 
$stime=microtime(true); //获取程序开始执行的时间 
echo "hello world";         //你执行的代码 
$etime=microtime(true);//获取程序执行结束的时间 
$total=$etime-$stime;   //计算差值 
echo "<br />{$total} times"; 
?> 

信息科技 2006-09-12 09:23:49 通过 网页 浏览(2741) 打印

上一篇

小学乘法表

下一篇

共有0条评论!

发表评论