Display DB queries, time spent and memory consumption

Adding this snippet to the functions.php of your wordpress theme will add a comment to the footer of your wordpress theme with the following statistics. Database 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} -->" ;
}
add_action( 'wp_footer', 'performance', 20 );

Be Sociable, Share!

Leave a comment