Switch tomography to median rather than avg

This commit is contained in:
Ross McFarland 2016-05-17 10:43:50 -07:00
parent 811c77c1b2
commit 4062920969
2 changed files with 11 additions and 3 deletions

View File

@ -600,7 +600,7 @@
{{ tomographyGraph tomography 336 }}
<p class="light small">Minimum: {{ tomography.min }}ms</p>
<p class="light small">Average: {{ tomography.avg }}ms</p>
<p class="light small">Median: {{ tomography.median }}ms</p>
<p class="light small">Maximum: {{ tomography.max }}ms</p>
</script>

View File

@ -299,7 +299,15 @@ App.NodesShowRoute = App.BaseRoute.extend({
}
});
var min = Math.min.apply(null, distances);
var avg = sum / distances.length;
var n = distances.length;
var halfN = Math.floor(n / 2);
var median;
if (n % 2) {
// odd
median = distances[halfN];
} else {
median = (distances[halfN - 1] + distances[halfN]) / 2;
}
var max = Math.max.apply(null, distances);
// Return a promise hash of the node and nodes
@ -310,7 +318,7 @@ App.NodesShowRoute = App.BaseRoute.extend({
distances: distances,
n: distances.length,
min: parseInt(min * 100) / 100,
avg: parseInt(avg * 100) / 100,
median: parseInt(median * 100) / 100,
max: parseInt(max * 100) / 100
},
node: Ember.$.getJSON(formatUrl(consulHost + '/v1/internal/ui/node/' + params.name, dc.dc, token)).then(function(data) {