推断当前页面加载是不是疾速,通常是直接在浏览器中接见网站,看本身的直观感觉是不是疾速。而客观的要领则是盘算详细的页面加载时候并显现出来给看。
1、在当前主题的functions.php文件增加下面的代码:
123456789101112131415161718 | 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;} |
2、在要显现加载时候的位置增加挪用代码:
1 | <?php echo timer_stop();?> |
3、保留后,到前台革新页面即可显现加载时候。

评论列表