Show user defined counters in the UI

This commit is contained in:
Johan Tibell 2011-12-29 12:52:21 -08:00
parent 68afa3416e
commit 8637295a67
2 changed files with 66 additions and 33 deletions

View file

@ -38,39 +38,48 @@
<h3>Productivity</h3>
<div id="productivity-plot" class="plot"></div>
</div>
<table class="span-8 last">
<tbody>
<tr>
<td class="span-5">Maximum residency</td>
<td id="max-bytes-used" class="span-3 value">0</td>
</tr>
<tr>
<td>Current residency</td>
<td id="current-bytes-used" class="value">0</td>
</tr>
<tr>
<td>Maximum slop</td>
<td id="max-bytes-slop" class="value">0</td>
</tr>
<tr>
<td>Current slop</td>
<td id="current-bytes-slop" class="value">0</td>
</tr>
<tr>
<td>Productivity (wall clock time)</td>
<td id="productivity-wall" class="value">0</td>
</tr>
<tr>
<td>Productivity (cpu time)</td>
<td id="productivity-cpu" class="value">0</td>
</tr>
<tr>
<td>Allocation rate</td>
<td id="allocation-rate" class="value">0</td>
</tr>
</tbody>
</table>
<div class="span-8 last">
<h3>GC Stats</h3>
<table>
<tbody>
<tr>
<td class="span-5">Maximum residency</td>
<td id="max-bytes-used" class="span-3 value">0</td>
</tr>
<tr>
<td>Current residency</td>
<td id="current-bytes-used" class="value">0</td>
</tr>
<tr>
<td>Maximum slop</td>
<td id="max-bytes-slop" class="value">0</td>
</tr>
<tr>
<td>Current slop</td>
<td id="current-bytes-slop" class="value">0</td>
</tr>
<tr>
<td>Productivity (wall clock time)</td>
<td id="productivity-wall" class="value">0</td>
</tr>
<tr>
<td>Productivity (cpu time)</td>
<td id="productivity-cpu" class="value">0</td>
</tr>
<tr>
<td>Allocation rate</td>
<td id="allocation-rate" class="value">0</td>
</tr>
</tbody>
</table>
<h3>Counters</h3>
<table id="counter-table">
<tbody>
</tbody>
</table>
<div>
</div>
<script type="text/javascript" src="monitor.js"></script>

View file

@ -132,6 +132,28 @@ $(function () {
listeners.push(onDataReceived);
}
function addDynamicCounters() {
var counters = {};
function onDataReceived(stats, time) {
$.each(stats, function(key, value) {
var elem;
if (key in counters) {
elem = counters[key];
} else {
// Add UI element
$("#counter-table > tbody:last").append(
'<tr><td>' + key + '</td><td class="value">N/A</td></tr>');
elem = $("#counter-table > tbody > tr > td:last");
counters[key] = elem;
}
if (!paused)
elem.text(value);
});
}
listeners.push(onDataReceived);
}
$(document).ready(function() {
// Metrics
var current_bytes_used = function(stats) { return stats.current_bytes_used };
@ -181,5 +203,7 @@ $(function () {
addCounter($("#productivity-wall"), productivity_wall_percent, formatPercent)
addCounter($("#productivity-cpu"), productivity_cpu_percent, formatPercent)
addCounter($("#allocation-rate"), allocation_rate, formatRate)
addDynamicCounters();
});
});