Original link: https://yunfanch.com/website/1940.html
After Typecho was updated to version 1.2, many codes on the Internet were not available. This is the page load time code available in 1.2.
Put the following code in the theme functions.php file
/** * 加载时间* @return bool */ 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; }
Then add in the theme foot.php file where the loading time needs to be placed
加载耗时:<?php echo timer_stop();?>
This article is reprinted from: https://yunfanch.com/website/1940.html
This site is for inclusion only, and the copyright belongs to the original author.