Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mike76-dev committed Mar 18, 2024
1 parent 936b9f1 commit c61f608
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions web-demo/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const apiBaseURL = '/hostscore/api';
var locations = ['eu'];//, 'us'];
var locations = ['eu', 'us'];
var hosts = [];
var moreHosts = false;
var offset = 0;
Expand Down Expand Up @@ -162,12 +162,14 @@ function browseHost(obj) {
let dl = 0;
let ttfb = 0;
let count = 0;
let items = [];
data.benchmarks.forEach(benchmark => {
if (benchmark.node == loc && benchmark.success == true) {
ul += benchmark.uploadSpeed;
dl += benchmark.downloadSpeed;
ttfb += benchmark.ttfb / 1e9;
count++;
items.push(benchmark);
}
});
if (count > 0) {
Expand All @@ -179,15 +181,15 @@ function browseHost(obj) {
upload: convertSize(ul) + '/s',
download: convertSize(dl) + '/s',
ttfb: ttfb.toFixed(2) + ' s',
data: data.benchmarks
data: items
});
} else {
benchmarks.push({
location: loc,
upload: 'N/A',
download: 'N/A',
ttfb: 'N/A',
data: data.benchmarks
data: items
});
}
if (benchmarks.length == locations.length) {
Expand All @@ -200,7 +202,7 @@ function browseHost(obj) {
upload += '<td style="text-align:center">' + benchmark.upload + '</td>';
download += '<td style="text-align:center">' + benchmark.download + '</td>';
ttfb += '<td style="text-align:center">' + benchmark.ttfb + '</td>';
header += '<th>' + l + '</th>';
header += '<th>' + l.toUpperCase() + '</th>';
});
header += '</tr>';
upload += '</tr>';
Expand Down Expand Up @@ -246,12 +248,14 @@ function browseHost(obj) {
let downtime = 0;
let activeHosts = 0;
if (host.interactions) locations.forEach(location => {
let date = new Date(host.interactions[location].lastSeen);
if (date > lastSeen) lastSeen = date;
uptime += host.interactions[location].uptime;
downtime += host.interactions[location].downtime;
let ah = host.interactions[location].activeHosts;
if (ah > activeHosts) activeHosts = ah;
if (host.interactions[location]) {
let date = new Date(host.interactions[location].lastSeen);
if (date > lastSeen) lastSeen = date;
uptime += host.interactions[location].uptime;
downtime += host.interactions[location].downtime;
let ah = host.interactions[location].activeHosts;
if (ah > activeHosts) activeHosts = ah;
}
});
document.getElementById('current-id').innerHTML = host.id;
document.getElementById('current-key').innerHTML = host.publicKey;
Expand Down

0 comments on commit c61f608

Please sign in to comment.