2

How do we manually output profiler results? For example if we wanted to output just few keys/sections? Right now when we switch on the profiler it will output all sections.

2

By default, in order to turn on Magento profiler, basically you need to do these two steps.

1) Make System > Configuration > Advanced > Developer > Debug > Profiler to Yes.

2) Uncomment the line Varien_Profiler::enable() which comes inside index.php.

So the second step is what you need to alter in your case. Since the line Varien_Profiler::enable() is included before the application runner code Mage::run(), this means profiler is enabled globally.

So what you want to do is, remove or comment out Varien_Profiler::enable() line of code from index.php and then put that line wherever you want to see the output. If you don't want to see the profiler buckets1 other than your custom profiler buckets, then after your buckets, you should disable profiler by putting Varien_Profiler::disable().

So basically, this is what you need to do.

//enables profiler
Varien_Profiler::enable();

//your custom profiler buckets starts
Varien_Profiler::start('unique_code')

/**
 * You custom code comes here
 *
 */

//your custom profiler buckets ends.
Varien_Profiler::stop('unique_code');

//disables profiler to avoid further profiling
Varien_Profiler::disable()

That's it. Now clear all cache and load the page again. You will see the profiler data only from your custom profiler buckets.

Note: Other than this manual enabling, I am not aware of any other better profiler enabling/disabling technique.


1 Profiler buckets are codes that comes in between a particular Varien_Profiler::start('unique_code') and Varien_Profiler::stop('unique_code').

|improve this answer|||||

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.