php有沒有可以檢測函數(shù)執(zhí)行時間的功能
1 回答

慕蓋茨4494581
TA貢獻1850條經(jīng)驗 獲得超11個贊
PHP 中的 microtime() 函數(shù)可以實現(xiàn)
microtime() 函數(shù)返回當前 Unix 時間戳和微秒數(shù)。
microtime(get_as_float)
參數(shù)說明
get_as_float 如果給出了 get_as_float 參數(shù)并且其值等價于 TRUE,該函數(shù)將返回一個浮點數(shù)。
本函數(shù)僅在支持 gettimeofday() 系統(tǒng)調(diào)用的操作系統(tǒng)下可用。
例如:
<?php
$start_time = microtime(true);
for($i=1;$i<=1000;$i++){
echo $i.'<br>';
}
$end_time = microtime(true);
echo '循環(huán)執(zhí)行時間為:'.($end_time-$start_time).' s';
?>
- 1 回答
- 0 關(guān)注
- 910 瀏覽
添加回答
舉報
0/150
提交
取消