jprofiler($prefix = ‘’)
This function is a proxy of Joomla\CMS\Profiler\Profiler::getInstance()
. It allows to use a profiler to debug performance inside twig layouts.
Parameters
string
$prefix Prefix used to distinguish profiler objects.
Returns
Joomla\CMS\Profiler\Profiler
A profiler instance.
Examples
{# Load a custom profiler with twig prefix. Best of jprofiler is that you can share profilers from PHP & twig to fully trace performance issues. #}
{% set profiler = jprofiler('twig') %}
{# echo memory & time consumed before doing something. If you want to hide in production while debugging an issue this you can use display: hidden in the container #}
<pre>{{ profiler.mark('before loading something') }}</pre>
{# Here what you want to debug #}
{# echo memory & time consumed after something. #}
<pre>{{ profiler.mark('after loading something') }}</pre>