diff --git a/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php b/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php index da3499a32a..ff5d9add06 100644 --- a/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php +++ b/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php @@ -53,10 +53,25 @@ class TraceableCache implements Cache, PhraseaCache $this->summary['calls_by_type'][$type]++; if (! array_key_exists($id, $this->summary['calls_by_key'])) { - $this->summary['calls_by_key'][$id] = 0; + $this->summary['calls_by_key'][$id] = [ + 'total' => 0, + 'reads'=> 0, + 'writes' => 0, + 'hits' => 0, + 'misses' => 0 + ]; } - $this->summary['calls_by_key'][$id]++; + if (! array_key_exists($type, $this->summary['calls_by_key'][$id])) { + $this->summary['calls_by_key'][$id][$type] = 0; + } + $this->summary['calls_by_key'][$id]['hits'] += $hit ? 1 : 0; + $this->summary['calls_by_key'][$id]['misses'] += $hit ? 0 : 1; + + $this->summary['calls_by_key'][$id]['reads'] += ($type == 'fetch' || $type == 'contains') ? 1 : 0; + $this->summary['calls_by_key'][$id]['writes'] += ($type == 'fetch' || $type == 'contains') ? 0 : 1; + + $this->summary['calls_by_key'][$id]['total']++; $this->calls[] = [ 'type' => $type, diff --git a/templates-profiler/cache.html.twig b/templates-profiler/cache.html.twig index 2cf231bc82..3bdce87625 100644 --- a/templates-profiler/cache.html.twig +++ b/templates-profiler/cache.html.twig @@ -80,7 +80,7 @@ -

Hit miss summary

+

HIT/MISS summary

@@ -129,15 +129,23 @@
- - + + + + + + - {% for callKey, count in collector.callSummary['calls_by_key'] %} + {% for callKey, stats in collector.callSummary['calls_by_key'] %} - + + + + + {% endfor %}
OperationCountKeyHitsMissesReadsWritesTotal
{{ callKey }}{{ count }}{{ stats['hits'] }}{{ stats['misses'] }}{{ stats['reads'] }}{{ stats['writes'] }}{{ stats['total'] }}