给网站加上显示页面查询次数、加载时间和内存占用的代码,记录一下,在主题functions.php中加上以下代码,然后在模板的footer.php最面的</html>加上<?php if(function_exists('performance')) performance(true) ;?>调用一下就行了。然后每个页面底部就会有这样的信息了:
26 queries in 1.629 seconds, using 11.33MB memory
//显示页面查询次数、加载时间和内存占用
function performance( $visible = false )
{
$stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory',
get_num_queries(),
timer_stop( 0, 3 ),
memory_get_peak_usage() / 1024 / 1024
);
echo $visible ? $stat : "<!-- {$stat} -->" ;
}

评论