Add by key aggregates in cache profiler

This commit is contained in:
Thibaud Fabre
2016-01-20 12:23:59 +01:00
parent 70cc35f306
commit 587b5beb27
2 changed files with 30 additions and 7 deletions

View File

@@ -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,

View File

@@ -80,7 +80,7 @@
</tr>
</table>
<h3>Hit miss summary</h3>
<h3>HIT/MISS summary</h3>
<table>
<thead>
@@ -129,15 +129,23 @@
<table>
<thead>
<tr>
<th>Operation</th>
<th>Count</th>
<th>Key</th>
<th>Hits</th>
<th>Misses</th>
<th>Reads</th>
<th>Writes</th>
<th>Total</th>
</tr>
</thead>
<tbody>
{% for callKey, count in collector.callSummary['calls_by_key'] %}
{% for callKey, stats in collector.callSummary['calls_by_key'] %}
<tr>
<td>{{ callKey }}</td>
<td>{{ count }}</td>
<td>{{ stats['hits'] }}</td>
<td>{{ stats['misses'] }}</td>
<td>{{ stats['reads'] }}</td>
<td>{{ stats['writes'] }}</td>
<td>{{ stats['total'] }}</td>
</tr>
{% endfor %}
</tbody>