Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Enable profiling (MAGE_PROFILER)

Magento profiling enables you to:

  • Enable a built-in profiler.

    You can use a built-in profiler with Magento to perform tasks such as analyzing performance. The nature of profiling depends on the analytical tools you use. We support multiple formats, including HTML.

  • Display dependency graphs on a Magento page. A dependency graph is a list of object dependencies and all of their all their dependencies, and all the dependencies for those dependencies, and so on.

    You should be particularly interested in the list of unused dependencies, which are objects that were created because they were requested in some constructor, but were never used (that is, none of their methods were called). As a result, processor time and memory spent to create these dependencies are wasted.

Magento provides the base functionality in Magento\Framework\Profiler.

Set MAGE_PROFILER

MAGE_PROFILER supports the following values:

You can set the value of MAGE_PROFILER in any of the ways discussed in Set the value of bootstrap parameters.

Updated