文章时效性提示

本文发布于 1852 天前,文中所描述的信息可能已发生改变

Typecho简单增加页面执行时间

执行时间只能做个参考,并不是特别精确,因为输出了时间之后,还进行了运算。

打开根目录 index.php

/** 载入配置支持 */上面加上

1
2
3
4
5
6
7
8
9
10
11
/**
* 加载时间
* @return bool
*/
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

即可

代码网上搜的,具体出处已经无从考究,有评论需要,分享出来吧~


Typecho简单增加页面执行时间
https://cuojue.org/read/typecho-add-total.html
作者
WeiCN
发布于
2020年3月6日
许可协议
Nickname
Email
Website
0/500
  • 😂
  • 😀
  • 😅
  • 😊
  • 🙂
  • 🙃
  • 😌
  • 😍
  • 😘
  • 😜
  • 😝
  • 😏
  • 😒
  • 🙄
  • 😳
  • 😡
  • 😔
  • 😫
  • 😱
  • 😭
  • 💩
  • 👻
  • 🙌
  • 🖕
  • 👍
  • 👫
  • 👬
  • 👭
  • 🌚
  • 🌝
  • 🙈
  • 💊
  • 😶
  • 🙏
  • 🍦
  • 🍉
  • 😣
  • 阿鲁
  • 贴吧
  • 微博
  • QQ
  • Bilibili
  • Emoji
0 comments