How to Show WordPress Query Count, Load Time, and Memory Usage in the Footer
If you have already added page load time to WordPress, this is a more complete version of the same idea. Besides load time, it also shows the number of database queries and peak memory usage directly in the page footer.
The setup is simple, and even beginners can handle it.

Step 1: Add the function to functions.php
In the WordPress admin area, go to Appearance → Theme File Editor, open the current theme’s functions.php, paste in the following code, and then save the file.

Use this code:
/*
让 WordPress 显示查询次数、查询时间及消耗内存
https://www.xyzbz.cn
*/
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 : "" ;
}
This function outputs three performance values:
- total query count
- page execution time
- peak memory usage
Step 2: Insert the output where you want it displayed
Next, add the following line wherever you want the performance stats to appear. In most cases, this is placed in footer.php.

Code:
本页面加载共:<?php if(function_exists('performance')) performance(true) ;?>
After saving the file, the footer will display the page’s query count, load time, and memory usage together.
If you only wanted to show load time before, this method gives you a fuller view of how the page is performing without needing any plugin.