Created
June 4, 2012 09:38
-
-
Save antoniofrignani/2867475 to your computer and use it in GitHub Desktop.
[WP] - Display DB queries, time spent and memory consumption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/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} -->" ; | |
} | |
add_action( 'wp_footer', 'performance', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment