用php得到页面的执行时间

来源:互联网 发布:shake it off 编辑:程序博客网 时间:2024/04/30 08:03

用php得到页面的执行时间

<?
/*
得到一个页面的执行时间,并显示出来。
get_microtime()函数可以保存在公共函数文件中供各个页面调用。
*/
function get_microtime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
?>
<?
//include('include/function.php');


$time_start = get_microtime();
echo "hello 1";
?>
<?
for($i=0;$i<100000;$i++)
{
 echo "$i aa";
}

?>

<?
echo "hello 2<br>";
$time_end = get_microtime();
$time = $time_end - $time_start;
echo $time;
?>
seconds.

原创粉丝点击