php 加载页面时间函数

2021-03-02 10:16:48 浏览数 (1)

代码语言:javascript复制
/**
* 加载时间
* @return bool
*/
function timer_start() {
global $timestart;
$mtime = explode( ' ', microtime() );
$timestart = $mtime[1]   $mtime[0];
return true;
}
timer_start();
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;
}

以下是我本地测试的我的电脑确实有点卡


版权属于:尹深

本文链接:https://cloud.tencent.com/developer/article/1795022

转载时须注明出处及本声明

(本站部分资源来自互联网收集整理!如有侵权请联系站长删除!!!)

0 人点赞