making bbPress (and WordPress) work better!

measuring WordPress performance

At some point you might get curious about how fast or slow WordPress is actually running, especially after a few strange reports that 2.0.4 is running slower.

I had tinkered with Jerome’s Query Diagnostics plugin:
http://vapourtrails.ca/wp-plugins (at the bottom of the page)

but on the WordPress IRC I just learned about
libertus’ interesting “performance probe” plugin
http://libertini.net/libertus/wordpress-plugins/performance-probe/
which looks even more fascinating… (also see his other posts here and here)

added: apparently I can’t use his plugin (as many people on shared servers will discover) since my PHP was not compiled with the “–enable-memory-limit configuration option” – there is also a php function called “memory-get-peak-usage” which might be helpful to some.

Be sure to see all the links on the right hand side on my main page here for more performance and development plugins/info on WordPress.

By the way I made a subtle enhancement to Jerome’s output, the code follows below the break:

This mod will not only point out the longest query for you, it will separate the query time vs. the rest of the php generation time for that page – remember you need to do a “view source” on the webpage as the diagnostic is hidden in the comments.


function jquerydiag_output() {
global $wpdb;

if (SAVEQUERIES) {
while($qposition < $wpdb->num_queries){
$qsubtime=$wpdb->queries[$qposition][1];
if ($qsubtime>$qmaxtime) {$qmaxtime=$qsubtime;$qmaxquery=$wpdb->queries[$qposition][0];}
$qtotal += $qsubtime;
$qposition++;
}
$timer_stop=timer_stop(0);
echo "<!-- \nquery count: ".$wpdb->num_queries." \n\n";
echo "total query time: ".round($qtotal,4)." seconds \n\n";
echo "total page time: ".round($timer_stop,4)." seconds.\n\n";
echo "page render difference: ".(round($timer_stop-$qtotal,4))." seconds \n\n";
echo "slowest call was: ".$qmaxquery."\n at ".round($qmaxtime,4)." seconds \n\n";
print_r($wpdb->queries);
echo "-->";
}
}

2 responses

  1. Pingback: Basic Thinking Blog » Wordpress Performance

  2. good job friend
    keet it up!
    http://www.3arab-hero.com

    November 25, 2007 at 12:05 pm

Leave a comment