diff --git a/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php b/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php index cbdaf1b9c9..598fb42321 100644 --- a/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php +++ b/lib/Alchemy/Phrasea/Core/Profiler/TraceableCache.php @@ -77,13 +77,36 @@ class TraceableCache implements Cache, PhraseaCache $this->summary['calls_by_key'][$id]['total']++; - $this->calls[] = [ + $lastCall = end($this->calls); + $callData = [ 'type' => $type, - 'key' => $id, + 'key' => $id, 'result' => $result, - 'hit' => (bool) $hit + 'hit' => (bool) $hit, + 'count' => 1 ]; + if ($this->compareCalls($lastCall, $callData)) { + $lastCall['count']++; + $callData = $lastCall; + + array_pop($this->calls); + } + + $this->calls[] = $callData; + } + + private function compareCalls(array $previousCall, array $currentCall) + { + $keys = [ 'type', 'key', 'result', 'hit']; + + foreach ($keys as $key) { + if ($previousCall[$key] != $currentCall[$key]) { + return false; + } + } + + return true; } /** diff --git a/templates-profiler/cache.html.twig b/templates-profiler/cache.html.twig index 2feffa7fb9..434505015e 100644 --- a/templates-profiler/cache.html.twig +++ b/templates-profiler/cache.html.twig @@ -166,22 +166,26 @@