执行时间只能做个参考,并不是特别精确,因为输出了时间之后,还进行了运算。
打开根目录 index.php
在/** 载入配置支持 */
上面加上
1 2 3 4 5 6 7 8 9 10 11
|
function timer_start() { global $timestart; $mtime = explode( ' ', microtime() ); $timestart = $mtime[1] + $mtime[0]; return true; } timer_start();
PHP
|
打开模板文件/footer.php
在合适位置加上
1
| Total <?php echo timer_stop();?>
PHP
|
在最后加上
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?php function timer_stop( $display = 0, $precision = 3 ) { global $timestart, $timeend; $mtime = explode( ' ', microtime() ); $timeend = $mtime[1] + $mtime[0]; $timetotal = number_format( $timeend - $timestart, $precision ); $r = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s"; if ( $display ) { echo $r; } return $r; } ?>
PHP
|
即可
代码网上搜的,具体出处已经无从考究,有评论需要,分享出来吧~