Query Count and Load Time in the Page Source
Adds an HTML comment at the bottom of front-end and admin pages with the number of database queries, generation time and peak memory. Visible to administrators only.
Opens WPIDE on
Code
$wpide_stats_comment = function () {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
printf(
"\n<!-- %d queries in %s seconds, peak memory %s -->\n",
(int) get_num_queries(),
esc_html( timer_stop( 0, 3 ) ),
esc_html( size_format( memory_get_peak_usage( true ), 1 ) )
);
};
add_action( 'wp_footer', $wpide_stats_comment, 9999 );
add_action( 'admin_footer', $wpide_stats_comment, 9999 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.