[WebProfilerBundle] Tweaked the Cache profiler panel

This commit is contained in:
Javier Eguiluz 2017-04-04 12:28:10 +02:00 committed by Fabien Potencier
parent 4a5f22bc1e
commit f9087c72c8

View File

@ -22,14 +22,15 @@
</div>
<div class="sf-toolbar-info-piece">
<b>Cache hits</b>
<span>{{ collector.totals.hits }}/{{ collector.totals.reads }}{% if collector.totals.hit_read_ratio is not null %} ({{ collector.totals.hit_read_ratio }}%){% endif %}</span>
<span>{{ collector.totals.hits }} / {{ collector.totals.reads }}{% if collector.totals.hit_read_ratio is not null %} ({{ collector.totals.hit_read_ratio }}%){% endif %}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Cache writes</b>
<span>{{ collector.totals.writes }}</span>
</div>
{% endset %}
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %}
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }}
{% endif %}
{% endblock %}
@ -39,127 +40,116 @@
{{ include('@WebProfiler/Icon/cache.svg') }}
</span>
<strong>Cache</strong>
<span class="count">
<span>{{ collector.totals.calls }}</span>
<span>{{ '%0.2f'|format(collector.totals.time * 1000) }} ms</span>
</span>
</span>
{% endblock %}
{% block panel %}
<h2>Cache</h2>
<div class="metrics">
<div class="metric">
<span class="value">{{ collector.totals.calls }}</span>
<span class="label">Total calls</span>
</div>
<div class="metric">
<span class="value">{{ '%0.2f'|format(collector.totals.time * 1000) }} <span class="unit">ms</span></span>
<span class="label">Total time</span>
</div>
<div class="metric-divider"></div>
<div class="metric">
<span class="value">{{ collector.totals.reads }}</span>
<span class="label">Total reads</span>
</div>
<div class="metric">
<span class="value">{{ collector.totals.writes }}</span>
<span class="label">Total writes</span>
</div>
<div class="metric">
<span class="value">{{ collector.totals.deletes }}</span>
<span class="label">Total deletes</span>
</div>
<div class="metric-divider"></div>
<div class="metric">
<span class="value">{{ collector.totals.hits }}</span>
<span class="label">Total hits</span>
</div>
<div class="metric">
<span class="value">{{ collector.totals.misses }}</span>
<span class="label">Total misses</span>
</div>
<div class="metric">
<span class="value">
{% if collector.totals.hit_read_ratio is null %}
n/a
{% else %}
{{ collector.totals.hit_read_ratio }} <span class="unit">%</span>
{% endif %}
</span>
<span class="label">Hits/reads</span>
</div>
</div>
<h2>Pools</h2>
<div class="sf-tabs">
{% for name, calls in collector.calls %}
<div class="tab {{ calls|length == 0 ? 'disabled' }}">
<h3 class="tab-title">{{ name }} <span class="badge">{{ collector.statistics[name].calls }}</span></h3>
<div class="tab-content">
<h3>Statistics</h3>
<div class="metrics">
{% for key, value in collector.statistics[name] %}
<div class="metric">
<span class="value">
{% if key == 'time' %}
{{ '%0.2f'|format(1000 * value.value) }} <span class="unit">ms</span>
{% elseif key == 'hit_read_ratio' %}
{% if value.value is null %}
n/a
{% else %}
{{ value }} <span class="unit">%</span>
{% endif %}
{% else %}
{{ value }}
{% endif %}
</span>
<span class="label">{{ key == 'hit_read_ratio' ? 'Hits/reads' : key|capitalize }}</span>
</div>
{% if key == 'time' or key == 'deletes' %}
<div class="metric-divider"></div>
{% endif %}
{% endfor %}
</div>
<h4>Calls</h4>
{% if calls|length == 0 %}
<div class="empty">
<p>No calls</p>
</div>
{% else %}
<table>
<thead>
<tr>
<th>#</th>
<th class="key">Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for call in calls %}
{% set separatorStyle = not loop.first ? ' style="border-top-width: medium;"' : '' %}
<tr>
<td class="font-normal text-small text-muted nowrap" rowspan="3"{{ separatorStyle|raw }}>{{ loop.index }}</td>
<th{{ separatorStyle|raw }}>{{ call.name }}</th>
<td{{ separatorStyle|raw }}>{{ profiler_dump(call.value.argument, maxDepth=2) }}</td>
</tr>
<tr>
<th>Result</th>
<td>{{ profiler_dump(call.value.result, maxDepth=1) }}</td>
</tr>
<tr>
<th>Time</th>
<td>{{ '%0.2f'|format((call.end - call.start) * 1000) }} ms</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% if collector.totals.calls == 0 %}
<div class="empty">
<p>No cache calls were made.</p>
</div>
{% else %}
<div class="metrics">
<div class="metric">
<span class="value">{{ collector.totals.calls }}</span>
<span class="label">Total calls</span>
</div>
{% endfor %}
</div>
<div class="metric">
<span class="value">{{ '%0.2f'|format(collector.totals.time * 1000) }} <span class="unit">ms</span></span>
<span class="label">Total time</span>
</div>
<div class="metric-divider"></div>
<div class="metric">
<span class="value">{{ collector.totals.reads }}</span>
<span class="label">Total reads</span>
</div>
<div class="metric">
<span class="value">{{ collector.totals.writes }}</span>
<span class="label">Total writes</span>
</div>
<div class="metric">
<span class="value">{{ collector.totals.deletes }}</span>
<span class="label">Total deletes</span>
</div>
<div class="metric-divider"></div>
<div class="metric">
<span class="value">{{ collector.totals.hits }}</span>
<span class="label">Total hits</span>
</div>
<div class="metric">
<span class="value">{{ collector.totals.misses }}</span>
<span class="label">Total misses</span>
</div>
<div class="metric">
<span class="value">
{{ collector.totals.hit_read_ratio ?? 0 }} <span class="unit">%</span>
</span>
<span class="label">Hits/reads</span>
</div>
</div>
<h2>Pools</h2>
<div class="sf-tabs">
{% for name, calls in collector.calls %}
<div class="tab {{ calls|length == 0 ? 'disabled' }}">
<h3 class="tab-title">{{ name }} <span class="badge">{{ collector.statistics[name].calls }}</span></h3>
<div class="tab-content">
{% if calls|length == 0 %}
<div class="empty">
<p>No calls were made for {{ name }} pool.</p>
</div>
{% else %}
<h4>Metrics</h4>
<div class="metrics">
{% for key, value in collector.statistics[name] %}
<div class="metric">
<span class="value">
{% if key == 'time' %}
{{ '%0.2f'|format(1000 * value.value) }} <span class="unit">ms</span>
{% elseif key == 'hit_read_ratio' %}
{{ value.value ?? 0 }} <span class="unit">%</span>
{% else %}
{{ value }}
{% endif %}
</span>
<span class="label">{{ key == 'hit_read_ratio' ? 'Hits/reads' : key|capitalize }}</span>
</div>
{% if key == 'time' or key == 'deletes' %}
<div class="metric-divider"></div>
{% endif %}
{% endfor %}
</div>
<h4>Calls</h4>
<table>
<thead>
<tr>
<th>#</th>
<th>Time</th>
<th>Call</th>
<th>Argument</th>
<th>Result</th>
</tr>
</thead>
<tbody>
{% for call in calls %}
<tr>
<td class="font-normal text-small text-muted nowrap">{{ loop.index }}</td>
<td>{{ '%0.2f'|format((call.end - call.start) * 1000) }} ms</td>
<td>{{ call.name }}()</td>
<td>{{ profiler_dump(call.value.argument, maxDepth=1) }}</td>
<td>{{ profiler_dump(call.value.result, maxDepth=1) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endblock %}