[教程] Typecho 页面加载耗时代码

查看: 465|回复: 0
crll 发表于 2023-2-25 21:07:36
  1. function timer_start() {
  2. global $timestart;
  3. $mtime = explode( ' ', microtime() );
  4. $timestart = $mtime[1] + $mtime[0];
  5. return true;
  6. }
  7. timer_start();

  8. function timer_stop( $display = 0, $precision = 3 ) {
  9. global $timestart, $timeend;
  10. $mtime = explode( ' ', microtime() );
  11. $timeend = $mtime[1] + $mtime[0];
  12. $timetotal = $timeend - $timestart;
  13. $r = number_format( $timetotal, $precision );
  14. if ( $display )
  15. echo $r;
  16. return $r;
  17. }
复制代码

然后,模板部分加入:

  1. <?php timer_stop() ?>
复制代码
博主论坛 bzlt.net
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于本站联系我们FAQ友情链接免责声明生存法则

Build with for "make" Copyright © 2020-2022. Powered by Discuz! GMT+8, 2024-4-17 02:38

快速回复 返回顶部 返回列表