計算php頁面運行時間的函數(shù)介紹
更新時間:2013年07月01日 16:00:13 作者:
本篇文章是對計算php頁面運行時間的函數(shù)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
一個計算php頁面運行時間的函數(shù)。
<?php
/*
@ 計算php程序運行時間
*/
function microtime_float()
{
list($usec, $sec) = explode(” “, microtime());
return ((float)$usec + (float)$sec);
}
//開始計時,放在頭部
$starttime = microtime_float();
//結(jié)束計時,放在最底部
$runtime = number_format((microtime_float() – $starttime), 4).'s';
//輸出
echo ‘RunTime:'.$runtime;
?>
復(fù)制代碼 代碼如下:
<?php
/*
@ 計算php程序運行時間
*/
function microtime_float()
{
list($usec, $sec) = explode(” “, microtime());
return ((float)$usec + (float)$sec);
}
//開始計時,放在頭部
$starttime = microtime_float();
//結(jié)束計時,放在最底部
$runtime = number_format((microtime_float() – $starttime), 4).'s';
//輸出
echo ‘RunTime:'.$runtime;
?>
相關(guān)文章
用PHP實現(xiàn)的四則運算表達(dá)式計算實現(xiàn)代碼
題目要求:有一個四則運算的字符串表達(dá)式,編寫一個函數(shù),計算四則運算的結(jié)果2011-08-08header中Content-Disposition的作用與使用方法
本文章詳細(xì)的介紹了關(guān)于php header中Content-disposition用法詳細(xì),有需要了解header用法的朋友可參考一下2012-06-06