首页 > SEO优化 > Typecho 页面加载耗时代码

Typecho 页面加载耗时代码

时间:2023年10月14日 分类:SEO优化 浏览量:102

Typecho 页面加载耗时代码

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 = $timeend - $timestart;
  $r = number_format( $timetotal, $precision );
  if ( $display )
    echo $r;
  return $r;
}

然后,模板部分加入:

<?php timer_stop() ?>

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

标签: