其实这个功能是个可有可无的功能,如果非要折腾,加上这个也效果非常棒。
在functions.php
文件中加入以下代码:
/*
让 WordPress 显示查询次数、查询时间及消耗内存
http://www.wpxzt.com
*/
function performance( $visible = true ) {
$stat = sprintf( '%d 次查询 | 用时 %.3f 秒 | 消耗 %.2fMB 内存',
get_num_queries(),
timer_stop( 0, 3 ),
memory_get_peak_usage() / 1024 / 1024
);
echo $visible ? $stat : "<!-- {$stat} -->" ;
}
如果调用的话可以用下面的代码进行(一般放在footer.php
文件中):
本页面加载共:<?php if(function_exists('performance')) performance(true) ;?>
来试试效果: