mirror of
https://github.com/amark/gun.git
synced 2025-06-03 20:56:43 +00:00
TEMPORARY test
This commit is contained in:
parent
79fac4cb45
commit
5bf425d2c4
@ -47,16 +47,17 @@
|
||||
var fetchData = async function(){
|
||||
// fetch the data from server
|
||||
var data = await (await fetch(url.value||(location.origin+'/gun/stats.radata'), {method: 'GET',mode: 'cors'})).json();
|
||||
data.over = (data.over/1000) || 15;
|
||||
$('#peers').text(data.peers.count);
|
||||
$('#time').text((data.peers.time / 1000 / 60).toFixed(0));
|
||||
$('#nodes').text(data.node.count);
|
||||
$('#hours').text((data.up.time / 60 / 60).toFixed(1));
|
||||
|
||||
Stats('memory').line.append(+new Date, data.memory.heapTotal / 1024 / 1024);
|
||||
try{ Stats('dam # in').line.append(+new Date, data.dam.in.count); }catch(e){}
|
||||
try{ Stats('dam in MB').line.append(+new Date, data.dam.in.done / 1024 / 1024); }catch(e){}
|
||||
try{ Stats('dam # out').line.append(+new Date, data.dam.out.count); }catch(e){}
|
||||
try{ Stats('dam out MB').line.append(+new Date, data.dam.out.done / 1024 / 1024); }catch(e){}
|
||||
try{ Stats('dam # in/s').line.append(+new Date, Math.round(data.dam.in.count / data.over)); }catch(e){}
|
||||
try{ Stats('dam in MB/s').line.append(+new Date, data.dam.in.done / 1024 / 1024 / data.over); }catch(e){}
|
||||
try{ Stats('dam # out/s').line.append(+new Date, Math.round(data.dam.out.count / data.over)); }catch(e){}
|
||||
try{ Stats('dam out MB/s').line.append(+new Date, data.dam.out.done / 1024 / 1024 / data.over); }catch(e){}
|
||||
|
||||
console.log('data',data);
|
||||
//fetch keys in all, these may be dynamically changing
|
||||
|
19
lib/stats.js
19
lib/stats.js
@ -26,11 +26,13 @@ Gun.on('opt', function(root){
|
||||
root.stats.up.count = (root.stats.up.count || 0) + 1;
|
||||
root.stats.stay = root.stats.stay || {};
|
||||
root.stats.gap = {};
|
||||
root.stats.over = +new Date;
|
||||
},1);
|
||||
setInterval(function(){
|
||||
var S = +new Date;
|
||||
if(!root.stats){ root.stats = {} }
|
||||
var S = +new Date;
|
||||
var stats = root.stats, tmp;
|
||||
stats.over = S - (stats.over||S);
|
||||
(stats.up||{}).time = process.uptime();
|
||||
stats.memory = process.memoryUsage() || {};
|
||||
stats.memory.totalmem = os.totalmem();
|
||||
@ -44,19 +46,24 @@ Gun.on('opt', function(root){
|
||||
stats.all = all;
|
||||
var dam = root.opt.mesh;
|
||||
if(dam){
|
||||
stats.dam = {'in': {count: dam.hear.c, done: dam.hear.d, long: dam.hear.long}, 'out': {count: dam.say.c, done: dam.say.d}};
|
||||
stats.dam = {'in': {count: dam.hear.c, done: dam.hear.d}, '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){
|
||||
stats.rad = rad;
|
||||
root.opt.store.stats = {get:{time:{}, count:0}, put: {time:{}, count:0}}; // reset
|
||||
}
|
||||
console.STAT && console.STAT(S, +new Date - S, 'stats'); S = +new Date;
|
||||
|
||||
fs.writeFile(__dirname+'/../stats.'+root.opt.file, JSON.stringify(stats, null, 2), function(err){ console.STAT && console.STAT(S, +new Date - S, 'stats stash') });
|
||||
console.STAT && console.STAT(S, +new Date - S, 'stats');
|
||||
S = +new Date;
|
||||
//fs.writeFile(__dirname+'/../stats.'+root.opt.file, JSON.stringify(stats, null, 2), function(err){ console.STAT && console.STAT(S, +new Date - S, 'stats stash') });
|
||||
// TEMPORARY TEST TO SEE HOW SLOW/FAST FS IS!!!
|
||||
fs.writeFileSync(__dirname+'/../stats.'+root.opt.file, JSON.stringify(stats, null, 2));
|
||||
console.log("[[[[[[[[[[", +new Date - S, "]]]]]]]]]]");
|
||||
// TEMPORARY TEST TO SEE HOW SLOW/FAST FS IS!!!
|
||||
console.STAT && console.STAT(S, +new Date - S, 'stats stash');
|
||||
stats.over = +new Date;
|
||||
stats.gap = {};
|
||||
}, 1000 * 15);
|
||||
Object.keys = Object.keys || function(o){ return Gun.obj.map(o, function(v,k,t){t(k)}) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user