I came to knew that there is a profiler in Magento 2, but I am not sure what it does and what it can be used for.
We can use a built-in profiler with Magento to perform tasks such as analyzing performance.
It can tell us in intricate detail which blocks of code are used in the loading of a slow page, and how long it takes each block to complete its task.
The nature of profiling depends on the analytical tools we use. Currently, Magento supports multiple formats like HTML, CSV or Firebug.
To enable profiler, we just need to add a
SetEnv MAGE_PROFILER "html" to .htaccess. We can also use "csvfile" or "firebug" instead of "html". In case of "csvfile", you can find the report in var/log dir.
Now if we go to any of the front facing pages, including the home page, at the bottom will be the profiler output.
The columns are as follows:
- Timer Id: This gives the name of the block of code being executed
- Time: The time it took to complete in seconds
- Avg: The average time it took to complete in seconds
- Cnt: Short for Count. This represents the number of times this individual block ran to generate the output required
- Emalloc: The amount of memory PHP ( the programming language on which Magento runs) assigned to this single operation. This is again represented in bytes.
- RealMem: The actual amount of memory used to perform the operation.
Apart from this basic MAGE_PROFILER, M2 also provides a database profiler to debug DB operations as well. Kindly refer to below links for more details about its configurations.
As of now My Knowledge
Magento 2 profiler will show
Total time (displays the total amount of time to run all queries on the page)
SQL (displays all SQL queries; the row header displays the count of queries)
Query Params (displays the parameters for each SQL query)
For more details check this link