Making a website faster is pretty much always the same process. It is not about guessing or tweaking something that might slow and checking if it got faster afterwards (ok, sometimes it’s actually this), but it is digging into what’s happening behind the scenes and actually measuring what’s eating time or memory.

When it comes to debugging my favorite tools are xdebug+kcachegrind and New Relic. You can get a lot of very useful information when checking their colorful graphical representation of your website rendering.

But those profilers don’t know anything about the structure of your application. And that is why there is a valid reason for Magento to have an internal profiler. This profiler is able to provide data that takes Magento specific information into account like controllers, actions, block, templates, events, or observers (and much more).

But did you ever try to use the profiler that comes with Magento? You have to activate it in the configuration settings (System > Configuration > Developer > Debug > Profiler) and also configure the allowed ip address (in System > Configuration > Developer > Developer Client Restrictions). In addition to those settings you have to modify index.php (ugly, isn’t it?) to make to profiler actually start collecting data, and as a result you’ll get something like this:

This output is very hard to read and won’t show what’s actually happening. It doesn’t reflect the structure of Magento’s page processing and it will sum up all buckets with the same label.




This is why I decided to create something better. And here it is: The Aoe_Profiler!

Aoe_Profiler is a drop-in replacement for the Varien_Profiler. It can be activated in the configuration and doesn’t require you to change any core files. It captures all data and also records its hierarchal information and displays everything in a nice way.

The total time spent in a bucket will be split into two parts:

  • the time spent in the bucket itself excluding time in sub-buckets: “own” (red)
  • and the sum or all sub-buckets. “sub” (blue)

By checking the own time you can easily find the buckets, that are actually eating all the time and memory.

Defining buckets

If there’s a section in the code that you want to check in detail you can always define own buckets starting with Varien_Profiler::start(‘<bucketName>’); and ending with Varien_Profiler::stop(‘<bucketName>’); Also check that the starting and stopping bucket names do exactly match or you’ll mess up the nesting of the buckets. If a broken nesting is detected it will be logged into var/log/system.log and buckets will be automatically closed in the correct order if possible.

Magento itself comes with a lot of useful buckets that allow you to start profiling right away without adding custom buckets.

Some buckets are very small and will blow up the output, so I decided to filter all buckets that are faster than 10ms as they might not be representing the bottlenecks you’re watching for. In future versions of Aoe_Profiler this will be a configurable setting.

Activate profiler

After installing the profiler you need to enable the profiler and set the ip settings like you would do for the regular built-in profiler (see above for paths to configuration settings).

Activating the collection of data is triggered by an url parameter ?profile=1. Or scroll to the bottom of the page. A message should appear with a pre-generated link. You can still uncomment Varien_Profiler::enable() in index.php if you want to. This will result in all pages being profiled. But usually this is not what you want und you might want to decide from page to page if the profiler should be used or not. Future versions will also listen to a cookie value and offer a switch that will enable you to profile pages without adding url parameters.

Btw, profiling works also for all adminhtml (backend) controllers.

Get the profiler

As always: You’ll find the Aoe_Profiler module on GitHub or download it directly from there:


A modman configuration file is included.

Now, go and check you Magento projects out and you’ll be surprised what the parts are, that are making your website so slow.

Btw, a nice developer tool that goes well with the Aoe_Profiler is my Aoe_TemplateHints. It will show you some detailed information on the block structure on the page. And if your Magento store is still slow there still Varnish, that will make it fly :)

Update: Version 0.2.0

I just released version 0.2.0 with lots of improvements, cleaned up code and new features:

  • different entry types including different icons (for templates, blocks, observers, events)
  • entries can be selected
  • dynamic filter (incl. slider interface)
  • database query profiler (enable profiler in local.xml as shown in the screencast)

Watch the screencast to see how to install Aoe_Profiler, how to work with it and to see the new features in action:

(Sorry for the bad video quality...)

Update: Version 0.2.1

And here is another feature: The slider interface now comes with a cubic scale that makes it much easier to select small filter values.


This website uses disqus for the commenting functionality. In order to protect your privacy comments are disabled by default.

Enable Comments