mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
add more stats
This commit is contained in:
parent
99ed43f5c4
commit
f4526238f3
@ -45,6 +45,10 @@
|
||||
</div>
|
||||
<div class="center"><span id="rerr"></span></div>
|
||||
|
||||
<div class="center leak" style="padding: 0 2em;">
|
||||
<div class="leak ct-daml ct-chart tall"></div>
|
||||
</div>
|
||||
|
||||
<div class="center leak" style="padding: 0 2em;">
|
||||
<div class="leak ct-cpu ct-chart ct-perfect-fourth tall"></div>
|
||||
</div>
|
||||
@ -130,6 +134,18 @@ stats.show = async function(data){ //$.getJSON(url.value||(location.origin+'/gun
|
||||
}});
|
||||
}catch(e){}
|
||||
|
||||
try{
|
||||
stats.daml = Object.values(data.dam['in'].long).map(function(n){ return n });
|
||||
new Chartist.Line('.ct-daml', {
|
||||
// A labels array that can contain any sort of values
|
||||
//labels: ['-1min', '-45s', '-30s', '-15s', '0'],
|
||||
// Our series array that contains series objects or in this case series data arrays
|
||||
series: [stats.daml]
|
||||
}, {fullWidth: true, axisY: {
|
||||
labelInterpolationFnc: function(v) { return v+'ms' }
|
||||
}});
|
||||
}catch(e){}
|
||||
|
||||
new Chartist.Line('.ct-cpu', {
|
||||
// A labels array that can contain any sort of values
|
||||
labels: ['-15min', '-5min', '1min'],
|
||||
|
2
gun.js
2
gun.js
@ -1973,9 +1973,11 @@
|
||||
try{msg = JSON.parse(raw);}catch(e){opt.log('DAM JSON parse error', e)}
|
||||
if(!msg){ return }
|
||||
var i = 0, m;
|
||||
var S = +new Date; // STATS!
|
||||
while(m = msg[i++]){
|
||||
mesh.hear(m, peer);
|
||||
}
|
||||
(mesh.hear.long || (mesh.hear.long = [])).push(+new Date - S);
|
||||
return;
|
||||
}
|
||||
if('{' === tmp || (Type.obj.is(raw) && (msg = raw))){
|
||||
|
@ -41,9 +41,10 @@ Gun.on('opt', function(root){
|
||||
stats.node.count = Object.keys(root.graph||{}).length;
|
||||
var dam = root.opt.mesh;
|
||||
if(dam){
|
||||
stats.dam = {'in': {count: dam.hear.c, done: dam.hear.d}, 'out': {count: dam.say.c, done: dam.say.d}};
|
||||
stats.dam = {'in': {count: dam.hear.c, done: dam.hear.d, long: dam.hear.long}, 'out': {count: dam.say.c, done: dam.say.d}};
|
||||
dam.hear.c = dam.hear.d = dam.say.c = dam.say.d = 0; // reset
|
||||
stats.peers.time = dam.bye.time || 0;
|
||||
dam.hear.long = [];
|
||||
}
|
||||
var rad = root.opt.store; rad = rad && rad.stats;
|
||||
if(rad){
|
||||
|
Loading…
x
Reference in New Issue
Block a user