php記錄頁面代碼執(zhí)行時間
來源:程序員人生 發(fā)布時間:2014-06-12 00:03:10 閱讀次數(shù):2431次
在php中要記錄頁面中代碼執(zhí)行時間我們只使用microtime函數(shù)生成時間,然后在最后把開始與結(jié)束時間相減即可解決了,核心代碼如下:
- $t1 = microtime(true);
-
- $t2 = microtime(true);
- echo '耗時'.round($t2-$t1,3).'秒';
上面為核心代碼下面我們詳細的來介紹一下,代碼如下:
- <?php
- $start_time=microtime(true);
- echo "hello world!<br />";
- $end_time=microtime(true);
- $total=$end_time-$start_time;
- echo "此php文件中代碼執(zhí)行了{$total}秒";
- ?>
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機掃描二維碼進行捐贈