Magento embeds a library to profile your Magento and detect some performance issues. In this recipe, we will see how to use it.
Activate the Profiler by navigating to System | Configuration | Advanced | Developer | Debug.
The second step is to enable the debugger in
YOUR_STORE.COM/index.php
near line 71 and remove the sharp so that it looks like the following:Varien_Profiler::enable();
If you can't find this line anywhere, add it somewhere before the last line (
Mage::run($mageRunCode, $mageRunType);
). If you have successfully enabled the profile, all your web pages will have a new footer similar to the following:
The table in your footer contains five columns; the first one, Code Profiler
, contains your timer name associated to the second column, Time
, which is the time when this timer has been reached. The third column, Cnt
, counts the number of times you launch the same timer. Finally, the last two columns, Emalloc
and RealMem
stand for the amount of memory allocated to PHP. The difference between those two is that the parameter true
is passed to the second one and is not passed to the first one.
The most important column to look at is the Cnt
column, because it counts the number of instances of a specific object. And to instantiate an object is time consuming. A high number in the Cnt
columns could mean that you made customizations that led to unnecessary object instantiations.
Using the built-in timers can be enough, but for an effective debug you should use your own.