mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +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->summary['calls_by_key'][$id]['total']++;
|
||||||
|
|
||||||
$this->calls[] = [
|
$lastCall = end($this->calls);
|
||||||
|
$callData = [
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'key' => $id,
|
'key' => $id,
|
||||||
'result' => $result,
|
'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>Call type</th>
|
||||||
<th>Key</th>
|
<th>Key</th>
|
||||||
<th>Hit / Miss</th>
|
<th>Hit / Miss</th>
|
||||||
|
<th>Count</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{% set callCount = 1 %}
|
||||||
{% for call in collector.calls %}
|
{% for call in collector.calls %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ loop.index }}</td>
|
<td>{{ callCount }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if call['type'] != 'fetch' %}
|
{% if call['type'] != 'fetch' %}
|
||||||
<strong>{{ call['type'] }}</strong>
|
<strong>{{ call['type'] }}</strong>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ call['type'] }}
|
{{ call['type'] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ call['key'] }}</td>
|
<td>{{ call['key'] }}</td>
|
||||||
<td>{% if call['hit'] %}HIT{% else %}<strong>MISS</strong>{% endif %}</td>
|
<td>{% if call['hit'] %}HIT{% else %}<strong>MISS</strong>{% endif %}</td>
|
||||||
|
<td>{{ call['count'] }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% set callCount = callCount + call['count'] %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Reference in New Issue
Block a user