Skip to content

Commit

Permalink
Merge pull request #90 from layanto/updated_profiler
Browse files Browse the repository at this point in the history
Add support for new style profiler 2.8/3.0
  • Loading branch information
tedivm committed Jan 5, 2016
2 parents c9ac225 + 858f0ef commit 7de7180
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 102 deletions.
Binary file removed Resources/public/images/stash.png
Binary file not shown.
4 changes: 4 additions & 0 deletions Resources/views/Profiler/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
349 changes: 247 additions & 102 deletions Resources/views/Profiler/layout.html.twig
Original file line number Diff line number Diff line change
@@ -1,135 +1,280 @@
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
{% extends app.request.isXmlHttpRequest ? '@WebProfiler/Profiler/ajax_layout.html.twig' : '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
{% set icon %}
<img width="22" height="28" alt="Memory Usage" style="vertical-align: middle;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAcCAYAAABlL09dAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wHGAALFQCM6LQAAAFwSURBVEjH7ZW9S4JRFIefRAoaAmlpbguCiKaGIqjh1FI0SV+vH6G2BmW4RlJG0Rj08RcE0aI3bGqPioagD6IpSEISGiSiBt/ATK+91ynwLBfOOffhx+/cD6jHv40GpVQ7EDXcnxCR+7JgAKVUGhgyAJ8CAyLyWVpw2esC8GEA7gesiopt1btA0AD+AnSISKacYoAYkDMAtwKJSlYgIs/AmuEQLaXUYHHCXdKwBdxqAFlN7UkH7jQ8Hd9z2gZuROTNXZQcBg6AZgPmOxAC2gAvEHXZUC9wZAjNASPAgy2ssdiKa6DX0IEM0GJfluYfHi8txi5qeRdWE/F5wFPpHNf05pQm3Lru4GyAyakJPJ6CmO6unkqtLkdgf8DHxvomyWSKfD7vSLHWipXlOGPjo6RPjglHQo680YJTKYU17ScSnsPyzehamxxZcX55VrjH2Sx7O/t/teKxKlgzrHLgV8AvIodVwQ7iDugTkav6b/8rvgBcMlqf0kD/YAAAAABJRU5ErkJggg=="/>
<span class="sf-toolbar-status sf-toolbar-status-green">{{ collector.calls }} call{% if collector.calls != 1 %}s{% endif %} / {{ collector.hits }} hit{% if collector.hits != 1 %}s{% endif %}</span>
{% endset %}
{% set text %}
<div class="sf-toolbar-info-piece">
<b>Total Response</b> <span class="sf-toolbar-status sf-toolbar-status-green">{{ collector.calls }} / {{ collector.hits }}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Default Queue</b> <span>{{ collector.default }}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Av. Drivers</b> <span>{{ collector.drivers|join(', ') }}</span>
</div>
{% for name, details in collector.caches %}
<hr style="border: 1px solid #ccc;">
{% if collector.calls > 0 or collector.hits > 0 %}
{% set profiler_markup_version = profiler_markup_version|default(1) %}

{% set icon %}
{% if profiler_markup_version == 1 %}
<img width="22" height="28" alt="Memory Usage" style="vertical-align: middle;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAcCAYAAABlL09dAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wHGAALFQCM6LQAAAFwSURBVEjH7ZW9S4JRFIefRAoaAmlpbguCiKaGIqjh1FI0SV+vH6G2BmW4RlJG0Rj08RcE0aI3bGqPioagD6IpSEISGiSiBt/ATK+91ynwLBfOOffhx+/cD6jHv40GpVQ7EDXcnxCR+7JgAKVUGhgyAJ8CAyLyWVpw2esC8GEA7gesiopt1btA0AD+AnSISKacYoAYkDMAtwKJSlYgIs/AmuEQLaXUYHHCXdKwBdxqAFlN7UkH7jQ8Hd9z2gZuROTNXZQcBg6AZgPmOxAC2gAvEHXZUC9wZAjNASPAgy2ssdiKa6DX0IEM0GJfluYfHi8txi5qeRdWE/F5wFPpHNf05pQm3Lru4GyAyakJPJ6CmO6unkqtLkdgf8DHxvomyWSKfD7vSLHWipXlOGPjo6RPjglHQo680YJTKYU17ScSnsPyzehamxxZcX55VrjH2Sx7O/t/teKxKlgzrHLgV8AvIodVwQ7iDugTkav6b/8rvgBcMlqf0kD/YAAAAABJRU5ErkJggg==" />

<span class="sf-toolbar-status sf-toolbar-status-green">{{ collector.calls }} call{% if collector.calls != 1 %}s{% endif %} / {{ collector.hits }} hit{% if collector.hits != 1 %}s{% endif %}</span>
{% else %}
{% set status = (collector.hits/collector.calls) < 0.33 ? 'red' : (collector.hits/collector.calls) < 0.66 ? 'yellow' : '' %}

{{ include('@TedivmStash/Profiler/icon.svg') }}

<span class="sf-toolbar-value">{{ collector.calls }}</span>
<span class="sf-toolbar-info-piece-additional-detail">
<span class="sf-toolbar-label">call{% if collector.calls != 1 %}s{% endif %}</span>
</span>
<span class="sf-toolbar-label">/</span>
<span class="sf-toolbar-value">{{ collector.hits }}</span>
<span class="sf-toolbar-info-piece-additional-detail">
<span class="sf-toolbar-label">hit{% if collector.hits != 1 %}s{% endif %}</span>
</span>
{% endif %}
{% endset %}

{% set text %}
<div class="sf-toolbar-info-piece">
<b><i>{{ name }}</i></b> <span class="sf-toolbar-status sf-toolbar-status-green">{{ details.calls }} / {{ details.hits }}</span>
<b>Total Response</b> <span class="sf-toolbar-status">{{ collector.calls }} / {{ collector.hits }}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Drivers</b> <span>{{ details.options.drivers|join(', ') }}</span>
<b>Default Queue</b> <span>{{ collector.default }}</span>
</div>
{% endfor %}
{% endset %}
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
<div class="sf-toolbar-info-piece">
<b>Av. Drivers</b> <span>{{ collector.drivers|join(', ') }}</span>
</div>
{% for name, details in collector.caches %}
<hr style="border: 1px solid #ccc;">
<div class="sf-toolbar-info-piece">
<b><i>{{ name }}</i></b> <span class="sf-toolbar-status">{{ details.calls }} / {{ details.hits }}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Drivers</b> <span>{{ details.options.drivers|join(', ') }}</span>
</div>
{% endfor %}
{% endset %}

{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status|default('') }) }}
{% endif %}
{% endblock %}

{% block menu %}
<span class="label">
<span class="icon"><img src="{{ asset('bundles/tedivmstash/images/stash.png') }}" alt="" /></span>
<strong>Stash</strong>
<span class="count">
<span>{{ collector.calls }} / {{ collector.hits }}</span>
</span>
</span>
{% set profiler_markup_version = profiler_markup_version|default(1) %}

{% if profiler_markup_version == 1 %}
<span class="label">
<span class="icon">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAkCAYAAAAD3IPhAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wJGRMhOUTTjFIAAAUYSURBVFjDzZhtiFRlFMd/55nryNqa7KaI9CER18pCWz/Y+gYFlnekD34QjMrs9VMRIuJbpURIUSRIRRAIRkH5kpWQc2M3o/ogBCuWq7TrW+smO75nq+vqzNx/H/bOOjvOjneXjXrgMneeOec8Z875n/8598L/aFk6na4BaoBR0Z7MzMoJS5KZKY5dSQ64bGadvu/3xHHGA+YAb5rZGEBA2HtmWX9CIHsro5KSZuYBf0hqDIKgGdjr+35FXc/M9gFdwAOSKDgh9Q+AmTGAgzeH5YaNiWb2UGT/YaC5kp7zff+8pM2Sus2skApKryFhoDelAkZL2tjY2OgqOhN9/gRsKtiIDAwLJoscW5DNZpfFEg6CYKqkLWbWoAqgGeJSBOpuM7vL9/1zlSKDpJPAbuBipDisVRtV6Shgy63SRBiG3cAnwB4zyw9vYPql/7EgCBZXTFNhpdNp38w+AiYONR0x5NqAeb7vnykbmSKgtQHbJV0tSmHZqwy/WMn3cjIAU4B30un0iFLSKxXOAJ+aWShpCpA3szAi4FIeKahlgWy0bwW+MjMVyRiQMLMLkk4BraVsPmBIgyC4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qm2BAe+nLm6OnpOTBmzO0/nD177udsNnsplUqphIGtG3E/Rv7ffS1Foqfn2omZMx+8GvOF03+7/gEOqoOB52x0lgAAAABJRU5ErkJggg==" alt="" />
</span>
<strong>Stash</strong>
<span class="count">
<span>{{ collector.calls }} / {{ collector.hits }}</span>
</span>
</span>
{% else %}
<span class="label {{ collector.calls == 0 and collector.hits == 0 ? 'disabled' }}">
<span class="icon">{{ include('@TedivmStash/Profiler/icon.svg') }}</span>
<strong>Stash</strong>
</span>
{% endif %}
{% endblock %}

{% block panel %}
<h2>Cache Information</h2>
<table>
<tr>
<th>Default Cache</th>
<td>{{ collector.default }}</td>
<tr>
<th>Available Drivers</th>
<td>{{ collector.drivers|join(', ') }}</td>
</tr>
<tr>
<th>Total Requests</th>
<td>{{ collector.calls }}</td>
</tr>
<tr>
<th>Total Hits</th>
<td>{{ collector.hits }}</td>
</tr>
</table>

{% for name, details in collector.caches %}
{% set profiler_markup_version = profiler_markup_version|default(1) %}

<h2>Cache Service: <i>{{ name }}</i></h2>
<h2>Cache Information</h2>
{% if profiler_markup_version == 1 %}
<table>
<tr>
<th>Drivers</th>
<td>{{ details.options.drivers|join(', ') }}</td>
</tr>
<tr>
<th>Calls</th>
<td>{{ details.calls }}</td>
</tr>
<th>Default Cache</th>
<td>{{ collector.default }}</td>
<tr>
<th>Hits</th>
<td>{{ details.hits }}</td>
<th>Available Drivers</th>
<td>{{ collector.drivers|join(', ') }}</td>
</tr>
<tr>
<th>Doctrine Adapter</th>
<td>{{ details.options.registerDoctrineAdapter ? 'true' : 'false' }}</td>
<th>Total Requests</th>
<td>{{ collector.calls }}</td>
</tr>
<tr>
<th>Cache In-Memory</th>
<td>{{ details.options.inMemory ? 'true' : 'false' }}</td>
<th>Total Hits</th>
<td>{{ collector.hits }}</td>
</tr>
</table>
{% else %}
<div class="metrics">
<div class="metric">
<span class="value">{{ collector.calls }}</span>
<span class="label">Total requests</span>
</div>
<div class="metric">
<span class="value">{{ collector.hits }}</span>
<span class="label">Total hits</span>
</div>
</div>
<table>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<th>Default Cache</th>
<td>{{ collector.default }}</td>
<tr>
<tr>
<th>Available Drivers</th>
<td>{{ collector.drivers|join(', ') }}</td>
</tr>
</tbody>
</table>
{% endif %}

{% for name, details in collector.caches %}
<h2>Cache Service: <i>{{ name }}</i></h2>
{% if profiler_markup_version == 1 %}
<table>
<tr>
<th>Drivers</th>
<td>{{ details.options.drivers|join(', ') }}</td>
</tr>
<tr>
<th>Calls</th>
<td>{{ details.calls }}</td>
</tr>
<tr>
<th>Hits</th>
<td>{{ details.hits }}</td>
</tr>
<tr>
<th>Doctrine Adapter</th>
<td>{{ details.options.registerDoctrineAdapter ? 'true' : 'false' }}</td>
</tr>
<tr>
<th>Cache In-Memory</th>
<td>{{ details.options.inMemory ? 'true' : 'false' }}</td>
</tr>
</table>
{% else %}
<div class="metrics">
<div class="metric">
<span class="value">{{ details.calls }}</span>
<span class="label">Requests</span>
</div>
<div class="metric">
<span class="value">{{ details.hits }}</span>
<span class="label">Hits</span>
</div>
</div>
<table>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<th>Drivers</th>
<td>{{ details.options.drivers|join(', ') }}</td>
</tr>
</tr>
<tr>
<th>Doctrine Adapter</th>
<td>{{ details.options.registerDoctrineAdapter ? 'true' : 'false' }}</td>
</tr>
<tr>
<th>Cache In-Memory</th>
<td>{{ details.options.inMemory ? 'true' : 'false' }}</td>
</tr>
</tbody>
</table>
{% endif %}

<h3>Driver Options</h3>
<table>
{% if profiler_markup_version == 1 %}
<table>
{% for name, options in details.options %}
{% if name != 'drivers' and name in details.options.drivers %}
<tr>
<th colspan="2"><h3 style="font-size: 16px; margin-bottom: 0;">{{ name }} settings</h3></th>
</tr>
{% if name in ['Memcache', 'Redis'] %}
{% for ovalue in options.servers %}
<tr>
<th>Server</th>
<td>{{ ovalue.server }}:{{ ovalue.port }} {% if ovalue.weight is defined %}(weight {{ ovalue.weight }}){% endif %}</td>
</tr>
{% endfor %}
{% else %}
{% for oname, ovalue in options %}
<tr>
<th>{{ oname }}</th>
{% if oname == 'filePermissions' or oname == 'dirPermissions' %}
<td>{{ "%o"|format(ovalue) }}
{% else %}
<td>{{ ovalue }}</td>
{% endif %}
</tr>
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
</table>
{% else %}
{% for name, options in details.options %}
{% if name != 'drivers' and name in details.options.drivers %}
<tr>
<th colspan="2"><h3 style="font-size: 16px; margin-bottom: 0;">{{ name }} settings</h3></th>
</tr>
{% if name in ['Memcache', 'Redis'] %}
{% for ovalue in options.servers %}
<tr>
<th>Server</th>
<td>{{ ovalue.server }}:{{ ovalue.port }} {% if ovalue.weight is defined %}(weight {{ ovalue.weight }}){% endif %}</td>
</tr>
{% endfor %}
{% else %}
{% for oname, ovalue in options %}
<table>
<thead>
<tr>
<th>{{ oname }}</th>
{% if oname == 'filePermissions' or oname == 'dirPermissions' %}
<td>{{ "%o"|format(ovalue) }}
{% else %}
<td>{{ ovalue }}</td>
{% endif %}
</tr>
{% endfor %}
{% endif %}
<th colspan="2">{{ name }} settings</th>
</th>
</thead>
<tbody>
{% if name in ['Memcache', 'Redis'] %}
{% for ovalue in options.servers %}
<tr>
<th>Server</th>
<td>{{ ovalue.server }}:{{ ovalue.port }} {% if ovalue.weight is defined %}(weight {{ ovalue.weight }}){% endif %}</td>
</tr>
{% endfor %}
{% else %}
{% for oname, ovalue in options %}
<tr>
<th>{{ oname }}</th>
{% if oname == 'filePermissions' or oname == 'dirPermissions' %}
<td>{{ "%o"|format(ovalue) }}
{% else %}
<td>{{ ovalue }}</td>
{% endif %}
</tr>
{% endfor %}
{% endif %}
</tbody>
{% endif %}
</table>
{% endfor %}
</table>
{% endif %}

<h3>Query Record</h3>
<table>
<tr>
<th>Request Key</th>
<th>Hit?</th>
<th>Returned Value</th>
</tr>
{% for query in details.queries %}
<tr>
<td>{{ query.key }}</td>
<td>{{ query.hit }}</td>
<td>{{ query.value }}</td>
</tr>
{% endfor %}
</table>


{% if not details.queries|length %}
<div class="empty">
<p>No queries were performed.</p>
</div>
{% else %}
<table>
<thead>
<tr>
<th>Request Key</th>
<th>Hit?</th>
<th>Returned Value</th>
</tr>
</thead>
<tbody>
{% for query in details.queries %}
<tr>
<td>{{ query.key }}</td>
<td>{{ query.hit }}</td>
<td>{{ query.value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endfor %}
{% endblock %}

0 comments on commit 7de7180

Please sign in to comment.