Default Magento installation has this great feature called “Profiler” that can play important role with your custom Magento development. This feature is meant to be be used for developer only. If used properly it can help you get valuable information of certain code parts during development.
To turn the “Profiler” on you have to do two things:
If you where successful with turning on “Profiler” you should see the output in the footer area of any Magento page, like shown on the photo below.
As you can see, it shows the table with following headers: “Code Profiler“, “Cnt“, “Emalloc“, “RealMem“.
“Code Profiler” column basically holds the value of your custom timer name. In my example, this would be “inchoo::test”. This is freely taken/assigned value. Try to use meaningful names for your timers.
“Cnt” column stands for “count”, and it holds the integer value of how many times have you “started” your timer with the same name. For example if I were to have my “Varien_Profiler::start(‘inchoo::test’);” called 2 times somewhere in my code, then my “Cnt” column would hold the value “2” in it. Like shown on the photo below.
“Emalloc” column stands for “Amount of memory allocated to PHP”. Its a mix of core PHP memory_get_usage() function without “true” parameter passed to it, minus timer values.
“RealMem” column also stands for “Amount of memory allocated to PHP” whose final value is also obtained trough memory_get_usage(true) function minus timer values but this time with “true” parameter passed in.
Please see the official PHP documentation on memory_get_usage() function for more info.
Besides these basic information, one can get more info by calling “Varien_Profiler::getSqlProfiler($conn);” like on the example shown below.
$conn = Mage::getSingleton('core/resource')->getConnection('core_setup'); $conn->getProfiler()->setEnabled(true); echo Varien_Profiler::getSqlProfiler($conn);
More info on this on of my older articles here.
Hope this demystifies the whole “profiler” topic a little bit.
It’s not a bad idea to use profiler features during development as you can react on time on certain possibly bloated code areas.