客户端
<head>
内容
<script language=javascript>
var t1 = new Date().getTime();
</script>
<body>
末尾内容
<script>
window.onload = function()
{
document.getElementById("TimeShow").innerHTML = (new Date().getTime()-t1) +"ms";
}
</script>
调用数据
<div>浏览器加载耗时: <span id="TimeShow"></span></div>
服务端
Joe主题
Joe主题自带本功能,可直接调用
<?php _endCountTime(); ?>
通用配置
编辑functions.php
文件
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;
}
调用数据
<?php echo timer_stop();?>