Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there any way to measure the time it takes for plugins to load and in which pages they load (without figuring out the entire code)? In addition, I would like to find out which plugins load files in which pages and find the ones that load on irrelevant ones.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Yes, Plugins effect site loading time.

There are many poorly written Plugins that make unnecessary database queries and load numerous files to the page.

The extra JavaScript and CSS files are not that big of deal unless you are using numerous plugins. I have worked on large sites that had 30 or 40 active plugins and the server would crash during any high traffic periods so it can be an issue.

To see what extra files are being loaded you can simply view source or use the net tab on Firebug.

alt text

Another good way to find external files loaded by plugins is to use W3 Total Cache's minify help wizard.

The wizard scans your theme and plugins and recommends the ones to combine and minify and for what page to load them on.

alt text

To monitor Plugin database queries and cpu time you can add the following code to the bottom of your footer.php:

<!--<?php echo $wpdb->num_queries;  
        _e('queries'); ?>. 
           timer_stop(1);  _e('seconds'); ?>.-->

This will allow you to view the source of each page and see how many queries are being made and how long it takes to make them.

Ex:

alt text

Of course this won't tell you what Plugin is responsible for the queries but allows you to do testing while disabling and activating different combinations.

share|improve this answer
    
Thanks Chris, I am familiar with net tab in firebug and use it often. I was looking for some kind of plugin monitor/logger that can tell me detailed info for each plugin. You say the only way is to see details for all running plugins? –  user1567 Nov 13 '10 at 17:18
    
Use the W3-Total Cache minify wizard and you will be able to tell what plugins are loading files. –  Chris_O Nov 13 '10 at 19:10

You could always concatenate them all into a new plugin and activate that instead, but you're honestly wasting your time. The maintainability from keeping them separate dwarves the performance benefit...

That said, be aware that using tons of plugins does affect your site's performance... You can easily measure that using benchmarking tools such as siege (http://www.joedog.org/index/siege-home).

Also, never lose sight that WP itself is a sluggish resource hog. You can micro-optimize a few milliseconds out of page load times, but considering any verbatim WP loads in 100ms or more to start with, rather than the more typical 10-40ms for apps written using a good php framework, I personally wouldn't bother.

share|improve this answer
    
Having skimmed only the code responsible for permalink resolution, I can see why WP is inefficient. How much can you improve by using some caching? –  Raphael Nov 13 '10 at 18:28
    
That affects things a lot, especially if you've many plugins that includes scripts or stylesheets. These can add significant delays when not concatenated using a caching plugin. –  Denis de Bernardy Nov 13 '10 at 22:19

Debug Queries plugin can also help in this task. If you want to be even more specific, and don't mind dealing with some code, you can use Plugin Test Drive (separates the tested plugins) and add the following function just before and after each plugin file is called:

<?php 
function getTime() 
    { 
    $a = explode (' ',microtime()); 
    return(double) $a[0] + $a[1]; 
    } 
$Start = getTime(); 
?>

<?php 
$End = getTime(); 
echo "Time taken = ".number_format(($End - $Start),2)." secs"; 
?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.