I am trying to find the best way to monitor which PHP code/functions, MySQL requests and/or plugins are slowing down pages on a site.

I know there are a bunch of different options out there including wordpress plugins and solutions involving firebug (firephp) but what do you guys feel is the best approach?

Personally I feel the ideal solution would be to have some type of code which can be installed by default with every wordpress install. Any debugging/monitoring/reporting would ONLY get executed if you added an optional entry to the end of the URL like ?=debug. For security purposes it would be even better if one would first have to login to the wordpress admin area and create a temp debug key which would create a hashed key and append it to the url (like debugkey=v09098v09aq2ov1a8923) which would only be available for 30 minutes.

But getting back to the actual debug info... I feel using firebug is great in many situations but optionally I feel it would be valuable if one could append something else to any URL which would for example overlay all the functions, hooks or filters used on a specific page along with the execution time for each.

In any case... I figured many of you here must have faced this issues as well and thus I would appreciate whatever solutions you are utilizing to solve your problems.

Please do outline how any specifics for others that might read this describing any specifics on installation and how to use it correctly.

UPDATED Running a Dedicated Linux Server


There are multiple tools and possibilities, and shure it would be nice to have something quick at hand. I know plugin authors who do offer debug flags so you can analyze what's going on quite easy.

As for plugins, I have not tested it but looked at some screenshots and it is at least informative: Debug Bar (Wordpress Plugin) and the BlackBox Debug Bar (Wordpress Plugin).

Another one is a hooktracer that is not that well known: SJ Hook Profiler.

I do heavily recommend xdebug for development and testing systems, it's a pleasure to have it if you need to profile or debug stuff.

  • Thanks for your answer. I am curious to know more about any plugins that may offer the debug flags you hinted at... Essentially there is so much information which can be obtained when debugging but ideal would be one that points out functions or queries which are taking too long... any thoughts? Feb 9 '11 at 0:16
  • @netcontructor.com that more for existing plugins and their debug, e.g. semiologic plugins and theme have this, but that is not a debug plugin. I need to look if I can get some of my gems to release. I have a error analyzer but it needs a specific PHP configuration and custom headers to control it. So not really ready to release.
    – hakre
    Feb 9 '11 at 0:31
  • I think Debug Bar scratches the sweet spot. If you are tinking around and want to try to fix something remotely without spending too much effort. Otherwise, you should use a local development environment with Eclipse PDT and Xdebug + Webgrind. Feb 9 '11 at 0:34
  • 1
    You can also use the plugin Debug Objects with many informations about the page/install
    – bueltge
    Feb 3 '12 at 11:53

XHProf (open source, part of Facebook stack for their performance monitoring) is pain to setup (at least for Windows person like me), but it's very thorough and convenient performance profiler tool for PHP.

I wish it had win version for my local test stack. :(

  • On windows boxes, install yourself a virtual computer and run linux on it. Works like a charm.
    – hakre
    Feb 9 '11 at 9:41
  • @hakre I do have that (I asked some questions if you remember while back), but it's much more messy and inconvenient than native Windows stack :(
    – Rarst
    Feb 9 '11 at 10:31
  • If you're saying so because linux is new to you - it makes much more fun for development than on windows. I know what I'm talking about, believe me ;)
    – hakre
    Feb 9 '11 at 15:10
  • @hakre Linux is not new to me, but I am into Windows for many many years. Messing with Linux just for the sake of messing with Linux is not worth it to me. It's what I call "switch tax" - no matter how something awesome is, never forget how much time and effort you will waste to switch from what you already know and efficient with.
    – Rarst
    Feb 9 '11 at 15:36
  • I'm only speaking about benefits in development which lowered the tax I payd everyday on windows by a large amount. Setting up dev boxes is a matter of minutes and the best tools are only available on linux when it comes to webdev. But I totally know what you're talking about, me is doing windows since ages, even prior web-development.
    – hakre
    Feb 9 '11 at 15:39

I can only recommend the Krumo php class that can be added within 10 sec to any installation and doesn't depend on any local setup. So even if you're out and away of your office you got a debug tool with you. Just be sure to load it after any other files and load it with if ( current_user_can('manage_options') ) krumo::enable(); so no guest or other user runs into your deugging messages if you're debugging something that's already live.


You don't indicate what your server arrangement is. If you are in a shared hosting environment you have limited options. If it's your own server, then you can install various profiling tools to get the Big Picture. Look at this thread over on SO for some options.

Also, slowness of the delivered page can be the result of a lot of things, only a few of which are PHP/MySQL related. You can have DNS problems, net congestion at either the client or server end, badly planned pages that have lots of JS loading early rather than late, etc. etc.

To test the fundamental food chain of network connection + server delivery of the basic HTML page, try using the Apache Benchmark program. Careful! You can beat the crap out of a server with this puppy, and your hosting company will not be amused if you do a one-person imitation of a DOS attack on their machine.

Update: OK, a dedicated Linux server gives you important options. In particular, I'll double-down on xdebug and it's ability to profile your code's execution. It's amazing how quickly a couple of runs under a profiler can shine a bright light on some innocent-looking function that's chewing up the machine.

If nothing immediately pops out at you, look for routines that seem to be taking more time than they should (whatever that means) and/or seem to be getting called a lot. The later can often be rectified by simply caching the results for certain values. If this is a general problem involving different, high-cost functions being called with different parameters, you can look at memoizing the affected functions. I've done this several times in Python, but not in PHP. Here is an article on one person's approach. There are more posts on this subject out there.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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