[wp-hackers] Help debugging long load time in plugin
Casey Bisson
casey.bisson at gmail.com
Fri Jan 2 02:14:36 GMT 2009
If you think it's DB interactions that are going slow, you can turn
out query logging and print out all the queries and how long they took
to execute. Just define SAVEQUERIES true in your wp-config.php and
then print_r( $wpdb->queries ) somewhere near the end of your code's
execution.
If the DB isn't the hold up, you can time other activities. There's a
simple timer function in wpdb, but it's not really public and only
tracks one thing at a time (that one thing is usually an active
query). I put an improved timer in my bSuite plugin that can track an
arbitrary number things. Take a look at the code here:
http://plugins.trac.wordpress.org/browser/bsuite/tags/4.0.3/bsuite.php#L2014
I use it like this:
global $bsuite;
$bsuite->timer_start( 'some_timer_name' );
do some stuff
$this->queries[] = array( 'some text about what is going', $bsuite-
>timer_stop( 'some_timer_name' ));
print_r( $this->queries[] );
--Casey
http://about.Scriblio.net/
http://MaisonBisson.com/
On Jan 1, 2009, at 8:45 PM, Derek Hogue wrote:
> Hey all,
>
> I recently released an update to my plugin (GigPress - <http://gigpress.com
> >), and it caused people on some hosts to be reduced to unacceptable
> load times on their WP installs (2-3 seconds in some cases). I
> can't find the common thread as of yet, as it's been a few different
> hosts (Bluehost and MediaTemple among them), but it must be somewhat
> rare, as more people than not have experienced no such slowdowns,
> and I can't recreate the issue on Dreamhost.
>
> The main thing that differentiates the new version (where these
> issues are occurring for some people) and the old version (where it
> did not) is that I've moved to using the shortcode API for GigPress'
> output - and I'm using the output buffer to capture the output and
> return or echo it, depending on whether it was called via the
> shortcode or called directly via a template tag.
>
> I should note that GigPress uses its own DB tables, and thus
> generates more MySQL queries than most plugins. There are a couple
> of issues related to this that I'd be grateful for any help with.
>
> 1) What's the best way to display the elapsed time of each function
> (or portion thereof) in my plugin when my debug mode is on? This
> would obviously help in finding the slowdown culprit in these cases.
>
> 2) Is there any way I can prevent my plugins queries from being run
> all the time, even when it's not being called by a post/page? As
> soon as GigPress is enabled, the queries for a default install jump
> way up, as though every function in the plug-in is being called on
> each page load.
>
> Any ideas would be greatly appreciated ...
>
> Thanks in advance, and happy new year,
> Derek
> --
> http://amphibian.info
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list