Surely you’ve heard about it before while looking for Magento 2 installation and launch lifehacks. So, it’s about time to put the things right.
Magento 2 has a built-in profiler, which is used to identify performance problems on the server. With the use of the profiler, you can see the execution time of certain chunks of code including the time for each query and executed parameters. Thus, we can get the execution time of code blocks and optimize memory and time spent.
Magento 2 supports 3 profiler formats:
The built-in profiler formats can be used for:
Magento profiler can help you with the store performance tuning before the store release or during the exploitation.
The old UI for enabling/disabling the profiler is not available in Magento 2 and the profiler is disabled by default.
To enable one of the profiler formats mentioned above, you can edit .htaccess (a configuration file for Apache Web Server software):
1. SetEnv MAGE_PROFILER "html" outputs in the footer of a web store page opened in a browser.
¡To enable the HTML profiler, you can also edit index.php with the next expression: $_SERVER["MAGE_PROFILER"]="html"!
2. SetEnv MAGE_PROFILER "csvfile" outputs into var/log/profiler.csv.
3. SetEnv MAGE_PROFILER "firebug" outputs into var/log/profiler.csv.