Typecho 给底部添加当前页面加载时间

2023-03-13 12:56:00 浏览数 (2)

在functions.php添加

代码语言:javascript复制
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;
}

在footer.php底部合适的位置添加

代码语言:javascript复制
<?php echo timer_stop();?>

0 人点赞