added avg block propagation

This commit is contained in:
cubedro 2015-04-28 18:44:41 +03:00
parent f202ff059a
commit 422b8eb061
4 changed files with 30 additions and 18 deletions

View File

@ -159,6 +159,7 @@ History.prototype.getNodePropagation = function(id)
History.prototype.getBlockPropagation = function() History.prototype.getBlockPropagation = function()
{ {
var propagation = []; var propagation = [];
var avgPropagation = 0;
_.forEach(this._items, function(n, key) _.forEach(this._items, function(n, key)
{ {
@ -171,6 +172,11 @@ History.prototype.getBlockPropagation = function()
}); });
}); });
if(propagation.length > 0)
{
var avgPropagation = Math.round(_.sum(propagation) / propagation.length);
}
var x = d3.scale.linear() var x = d3.scale.linear()
.domain([MIN_PROPAGATION_RANGE, MAX_PROPAGATION_RANGE]) .domain([MIN_PROPAGATION_RANGE, MAX_PROPAGATION_RANGE])
.interpolate(d3.interpolateRound); .interpolate(d3.interpolateRound);
@ -187,7 +193,7 @@ History.prototype.getBlockPropagation = function()
return {x: val.x, dx: val.dx, y: val.y, frequency: val.length, cumulative: freqCum, cumpercent: cumPercent}; return {x: val.x, dx: val.dx, y: val.y, frequency: val.length, cumulative: freqCum, cumpercent: cumPercent};
}); });
return histogram; return {histogram: histogram, avg: avgPropagation};
} }
History.prototype.getUncleCount = function() History.prototype.getUncleCount = function()

View File

@ -14,6 +14,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
$scope.lastDifficulty = 0; $scope.lastDifficulty = 0;
$scope.upTimeTotal = 0; $scope.upTimeTotal = 0;
$scope.avgBlockTime = 0; $scope.avgBlockTime = 0;
$scope.blockPropagationAvg = 0;
$scope.avgHashrate = 0; $scope.avgHashrate = 0;
$scope.uncleCount = 0; $scope.uncleCount = 0;
$scope.bestStats = {}; $scope.bestStats = {};
@ -140,7 +141,8 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
break; break;
case "blockPropagationChart": case "blockPropagationChart":
$scope.blockPropagationChart = data; $scope.blockPropagationChart = data.histogram;
$scope.blockPropagationAvg = data.avg;
break; break;
@ -159,7 +161,8 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
$scope.difficultyChart = data.difficulty; $scope.difficultyChart = data.difficulty;
$scope.transactionDensity = data.transactions; $scope.transactionDensity = data.transactions;
$scope.gasSpending = data.gasSpending; $scope.gasSpending = data.gasSpending;
$scope.blockPropagationChart = data.propagation; $scope.blockPropagationChart = data.propagation.histogram;
$scope.blockPropagationAvg = data.propagation.avg;
$scope.uncleCountChart = data.uncleCount; $scope.uncleCountChart = data.uncleCount;
$scope.uncleCount = data.uncleCount[0] + data.uncleCount[1]; $scope.uncleCount = data.uncleCount[0] + data.uncleCount[1];

View File

@ -175,20 +175,20 @@ angular.module('netStatsApp.filters', [])
}; };
}) })
.filter('propagationAvgTimeClass', function() { .filter('propagationAvgTimeClass', function() {
return function(stats) { return function(propagationAvg, active) {
if( ! stats.active) if( ! active)
return 'text-gray'; return 'text-gray';
if(stats.propagationAvg == 0) if(propagationAvg == 0)
return 'text-info'; return 'text-info';
if(stats.propagationAvg < 1000) if(propagationAvg < 1000)
return 'text-success'; return 'text-success';
if(stats.propagationAvg < 3000) if(propagationAvg < 3000)
return 'text-warning'; return 'text-warning';
if(stats.propagationAvg < 7000) if(propagationAvg < 7000)
return 'text-orange'; return 'text-orange';
return 'text-danger' return 'text-danger'
@ -232,30 +232,33 @@ angular.module('netStatsApp.filters', [])
}; };
}) })
.filter('blockPropagationFilter', function() { .filter('blockPropagationFilter', function() {
return function(ms) { return function(ms, prefix) {
if(typeof prefix === 'undefined')
prefix = '+';
var result = 0; var result = 0;
if(ms < 1000) { if(ms < 1000) {
return (ms === 0 ? "" : "+") + ms + " ms"; return (ms === 0 ? "" : prefix) + ms + " ms";
} }
if(ms < 1000*60) { if(ms < 1000*60) {
result = ms/1000; result = ms/1000;
return "+" + result.toFixed(1) + " s"; return prefix + result.toFixed(1) + " s";
} }
if(ms < 1000*60*60) { if(ms < 1000*60*60) {
result = ms/1000/60; result = ms/1000/60;
return "+" + Math.round(result) + " min"; return prefix + Math.round(result) + " min";
} }
if(ms < 1000*60*60*24) { if(ms < 1000*60*60*24) {
result = ms/1000/60/60; result = ms/1000/60/60;
return "+" + Math.round(result) + " h"; return prefix + Math.round(result) + " h";
} }
result = ms/1000/60/60/24; result = ms/1000/60/60/24;
return "+" + Math.round(result) + " days"; return prefix + Math.round(result) + " days";
}; };
}) })
.filter('avgTimeFilter', function() { .filter('avgTimeFilter', function() {

View File

@ -101,10 +101,10 @@ block content
span.big-details.spark-difficulty span.big-details.spark-difficulty
div.col-xs-3.stat-holder.xpull-right div.col-xs-3.stat-holder.xpull-right
div.big-info.chart.xdouble-chart.text-info div.big-info.chart.xdouble-chart(class="{{ blockPropagationAvg | propagationAvgTimeClass : true }}")
//- i.icon-gas //- i.icon-gas
span.small-title block propagation span.small-title block propagation
//- span.small-value {{ lastDifficulty | number }} span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }}
histogram.big-details.d3-blockpropagation(data="blockPropagationChart") histogram.big-details.d3-blockpropagation(data="blockPropagationChart")
div.col-xs-3.stat-holder.pull-right div.col-xs-3.stat-holder.pull-right
@ -205,5 +205,5 @@ block content
div.propagationBox div.propagationBox
span {{node.stats.block.propagation | blockPropagationFilter}} span {{node.stats.block.propagation | blockPropagationFilter}}
td.peerPropagationChart(class="{{node.id}}") td.peerPropagationChart(class="{{node.id}}")
td(class="{{ node.stats | propagationAvgTimeClass }}") {{ node.stats.propagationAvg | blockPropagationFilter }} td(class="{{ node.stats.propagationAvg | propagationAvgTimeClass : node.stats.active }}") {{ node.stats.propagationAvg | blockPropagationFilter : '' }}
td(class="{{ node.stats.uptime | upTimeClass : node.stats.active }}") {{ node.stats.uptime | upTimeFilter }} td(class="{{ node.stats.uptime | upTimeClass : node.stats.active }}") {{ node.stats.uptime | upTimeFilter }}