其实这个功能是个可有可无的功能,如果非要折腾,加上这个也效果非常棒。

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) ;?>

来试试效果:

参与评论