From d366d290e73fb72eebf49bc1c0ddb5e442b481f3 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 23 Mar 2017 19:29:14 +0100 Subject: [PATCH 1/6] [WebProfilerBundle] Fix rendering empty cache calls --- .../Resources/views/Collector/cache.html.twig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index c71a69181736c..26fb2ae286317 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -99,12 +99,12 @@ {% endfor %} -

Calls for '{{ name }}'

- {% if not collector.totals.calls %} -

- No calls. -

+

Calls for '{{ name }}'

+ {% if calls|length == 0 %} +
+

No calls

+
{% else %} From 39972cccabad7dbf7dc8a70a676088cb5ef26062 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 23 Mar 2017 20:00:23 +0100 Subject: [PATCH 2/6] [WebProfilerBundle] Switch to tabs for cache panel --- .../Resources/views/Collector/cache.html.twig | 119 +++++++++--------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index 26fb2ae286317..f43fcb540dc8f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -83,64 +83,71 @@ - {% for name, calls in collector.calls %} -

Statistics for '{{ name }}'

-
- {% for key, value in collector.statistics[name] %} -
- - {% if key == 'time' %} - {{ '%0.2f'|format(1000*value.value) }} ms - {% else %} - {{ value }} - {% endif %} - - {{ key|capitalize }} -
- {% endfor %} -
+
+ {% for name, calls in collector.calls %} +
+

{{ name }} {{ collector.statistics[name].calls }}

-

Calls for '{{ name }}'

- {% if calls|length == 0 %} -
-

No calls

-
- {% else %} -
- - - - - - - - {% for i, call in calls %} - - - - - - - - - - - - - - - - +
+

Statistics

+
+ {% for key, value in collector.statistics[name] %} +
+ + {% if key == 'time' %} + {{ '%0.2f'|format(1000*value.value) }} ms + {% else %} + {{ value }} + {% endif %} + + {{ key|capitalize }} +
+ {% endfor %} +
- {% endfor %} -
+

Calls

+ {% if calls|length == 0 %} +
+

No calls

+
+ {% else %} +
KeyValue
#{{ i }}Pool::{{ call.name }}
Argument{{ profiler_dump(call.argument, maxDepth=2) }}
Results - {% if call.result != false %} - {{ profiler_dump(call.result, maxDepth=1) }} - {% endif %} -
Time{{ '%0.2f'|format((call.end - call.start) * 1000) }} ms
+ + + + + + + + {% for i, call in calls %} + + + + + + + + + + + + + + + + -
KeyValue
#{{ i }}Pool::{{ call.name }}
Argument{{ profiler_dump(call.argument, maxDepth=2) }}
Results + {% if call.result != false %} + {{ profiler_dump(call.result, maxDepth=1) }} + {% endif %} +
Time{{ '%0.2f'|format((call.end - call.start) * 1000) }} ms
- {% endif %} - {% endfor %} + {% endfor %} + + + {% endif %} + + + {% endfor %} + {% endblock %} From 40a6c7527afe9a81caf1aefb9953873ddd9f9fec Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 23 Mar 2017 22:12:32 +0100 Subject: [PATCH 3/6] improved metric formatting --- .../Resources/views/Collector/cache.html.twig | 43 +++++++++++++------ .../DataCollector/CacheDataCollector.php | 16 +++---- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index f43fcb540dc8f..66bf640dcb8cc 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -22,7 +22,7 @@
Cache hits - {{ collector.totals.hits }}/{{ collector.totals.reads }} ({{ collector.totals['hits/reads'] }}) + {{ collector.totals.hits }}/{{ collector.totals.reads }}{% if collector.totals.hit_read_ratio is not null %} ({{ collector.totals.hit_read_ratio }}%){% endif %}
Cache writes @@ -54,21 +54,14 @@ Total calls
- {{ '%0.2f'|format(collector.totals.time * 1000) }} ms + {{ '%0.2f'|format(collector.totals.time * 1000) }} ms Total time
+
{{ collector.totals.reads }} Total reads
-
- {{ collector.totals.hits }} - Total hits -
-
- {{ collector.totals.misses }} - Total misses -
{{ collector.totals.writes }} Total writes @@ -77,8 +70,23 @@ {{ collector.totals.deletes }} Total deletes
+
+
+ {{ collector.totals.hits }} + Total hits +
- {{ collector.totals['hits/reads'] }} + {{ collector.totals.misses }} + Total misses +
+
+ + {% if collector.totals.hit_read_ratio is null %} + n/a + {% else %} + {{ collector.totals.hit_read_ratio }} % + {% endif %} + Hits/reads
@@ -95,13 +103,22 @@
{% if key == 'time' %} - {{ '%0.2f'|format(1000*value.value) }} ms + {{ '%0.2f'|format(1000*value.value) }} ms + {% elseif key == 'hit_read_ratio' %} + {% if value.value is null %} + n/a + {% else %} + {{ value }} % + {% endif %} {% else %} {{ value }} {% endif %} - {{ key|capitalize }} + {{ key == 'hit_read_ratio' ? 'Hits/reads' : key|capitalize }}
+ {% if key == 'time' or key == 'deletes' %} +
+ {% endif %} {% endfor %} diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index edbd726351100..76d24f38c32f7 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -103,10 +103,10 @@ private function calculateStatistics() 'calls' => 0, 'time' => 0, 'reads' => 0, - 'hits' => 0, - 'misses' => 0, 'writes' => 0, 'deletes' => 0, + 'hits' => 0, + 'misses' => 0, ); /** @var TraceableAdapterEvent $call */ foreach ($calls as $call) { @@ -138,9 +138,9 @@ private function calculateStatistics() } } if ($statistics[$name]['reads']) { - $statistics[$name]['hits/reads'] = round(100 * $statistics[$name]['hits'] / $statistics[$name]['reads'], 2).'%'; + $statistics[$name]['hit_read_ratio'] = round(100 * $statistics[$name]['hits'] / $statistics[$name]['reads'], 2); } else { - $statistics[$name]['hits/reads'] = 'N/A'; + $statistics[$name]['hit_read_ratio'] = null; } } @@ -157,10 +157,10 @@ private function calculateTotalStatistics() 'calls' => 0, 'time' => 0, 'reads' => 0, + 'writes' => 0, + 'deletes' => 0, 'hits' => 0, 'misses' => 0, - 'writes' => 0, - 'deletes' => 0, ); foreach ($statistics as $name => $values) { foreach ($totals as $key => $value) { @@ -168,9 +168,9 @@ private function calculateTotalStatistics() } } if ($totals['reads']) { - $totals['hits/reads'] = round(100 * $totals['hits'] / $totals['reads'], 2).'%'; + $totals['hit_read_ratio'] = round(100 * $totals['hits'] / $totals['reads'], 2); } else { - $totals['hits/reads'] = 'N/A'; + $totals['hit_read_ratio'] = null; } return $totals; From 31d19337dd7f252b012d41e7eb0cf98ac6c3980b Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 23 Mar 2017 23:08:21 +0100 Subject: [PATCH 4/6] improved/fixed profiler_dump in call table --- .../Resources/views/Collector/cache.html.twig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index 66bf640dcb8cc..5f03e6872b404 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -143,14 +143,12 @@ Argument - {{ profiler_dump(call.argument, maxDepth=2) }} + {{ profiler_dump(call.value.argument, maxDepth=2) }} Results - {% if call.result != false %} - {{ profiler_dump(call.result, maxDepth=1) }} - {% endif %} + {{ profiler_dump(call.value.result, maxDepth=1) }} From bc04a20920d5dfe83680ff4297636c6a25b88b94 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Fri, 24 Mar 2017 20:02:19 +0100 Subject: [PATCH 5/6] improves tabs top spacing --- .../WebProfilerBundle/Resources/views/Collector/cache.html.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index 5f03e6872b404..db1b16ab30584 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -91,6 +91,7 @@ +

Pools

{% for name, calls in collector.calls %}
From c345e66565930778233f82387b49f902c02ce278 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Fri, 24 Mar 2017 20:41:45 +0100 Subject: [PATCH 6/6] improved overall table --- .../Resources/views/Collector/cache.html.twig | 30 ++++++++----------- .../DataCollector/CacheDataCollector.php | 2 +- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index db1b16ab30584..f168e84f4a267 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -104,7 +104,7 @@
{% if key == 'time' %} - {{ '%0.2f'|format(1000*value.value) }} ms + {{ '%0.2f'|format(1000 * value.value) }} ms {% elseif key == 'hit_read_ratio' %} {% if value.value is null %} n/a @@ -131,32 +131,28 @@ {% else %} - - - - - - - {% for i, call in calls %} - - + + + + + + {% for call in calls %} + {% set separatorStyle = not loop.first ? ' style="border-top-width: medium;"' : '' %} - - + + {{ call.name }} + {{ profiler_dump(call.value.argument, maxDepth=2) }} - - + + - {% endfor %}
KeyValue
#{{ i }}Pool::{{ call.name }}#KeyValue
Argument{{ profiler_dump(call.value.argument, maxDepth=2) }}{{ loop.index }}
Results - {{ profiler_dump(call.value.result, maxDepth=1) }} - Result{{ profiler_dump(call.value.result, maxDepth=1) }}
Time {{ '%0.2f'|format((call.end - call.start) * 1000) }} ms
diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index 76d24f38c32f7..4f9bc73983639 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -157,7 +157,7 @@ private function calculateTotalStatistics() 'calls' => 0, 'time' => 0, 'reads' => 0, - 'writes' => 0, + 'writes' => 0, 'deletes' => 0, 'hits' => 0, 'misses' => 0,