The profiler

Magento has an in-built profiler that can be used to identify performance problems on the server side. In a nutshell, the profiler can tell us the execution time of certain chunks of code. There is nothing that great with its behavior. We can only get the execution time of code blocks or individual expressions that have been wrapped by the profiler's start and stop methods. On its own, Magento calls for the profiler extensively across its code. However, we can't see it in effect as the profiler output is disabled by default.

Magento supports three profiler outputs, namely html, csvfile, and firebug.

To enable the profiler, we can edit .htaccess and add one of the following expressions:

  • SetEnv MAGE_PROFILER "html"
  • SetEnv MAGE_PROFILER ...

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.