mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Aggregate repeated calls to reduce size of collected data
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -166,22 +166,26 @@
|
||||
<th>Call type</th>
|
||||
<th>Key</th>
|
||||
<th>Hit / Miss</th>
|
||||
<th>Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set callCount = 1 %}
|
||||
{% for call in collector.calls %}
|
||||
<tr>
|
||||
<td>{{ loop.index }}</td>
|
||||
<td>{{ callCount }}</td>
|
||||
<td>
|
||||
{% if call['type'] != 'fetch' %}
|
||||
<strong>{{ call['type'] }}</strong>
|
||||
<strong>{{ call['type'] }}</strong>
|
||||
{% else %}
|
||||
{{ call['type'] }}
|
||||
{{ call['type'] }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ call['key'] }}</td>
|
||||
<td>{% if call['hit'] %}HIT{% else %}<strong>MISS</strong>{% endif %}</td>
|
||||
<td>{{ call['count'] }}</td>
|
||||
</tr>
|
||||
{% set callCount = callCount + call['count'] %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user