Add this to your theme’s functions.php file.
1 2 3 4 5 6 7 8 9 10 | 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):
1 | add_action( 'wp_footer', 'performance', 20 ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.