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:
→ Working on speed optimization? The Google Page Speed Optimization plugin can help you to boost website performance by optimizing code, images, and enabling lazy loading. Or get the speed optimization pack with 4 plugins that will rocket your website speed.
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 Magento 2 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.
There are cases when HTML profiler won’t work after you enabled them in Magento. The reason is that the HTML code causes javascript execution errors. You can crack the problem by using other profile modes (csvfile, etc.) or make sure the HTML profiler doesn’t influence the functionality.
Login and Registration Form