Skip to content

Instantly share code, notes, and snippets.

@habibmac
Created June 6, 2012 16:43
Show Gist options
  • Save habibmac/2883169 to your computer and use it in GitHub Desktop.
Save habibmac/2883169 to your computer and use it in GitHub Desktop.
WP: Display DB queries, time spent, and memory consumption
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} -->" ;
}
// Then this code below the code above which will automatically insert the code above into the footer of your public website (make sure your theme is calling wp_footer):
add_action( 'wp_footer', 'performance', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment