MCPcopy Create free account
hub / github.com/BrainicHQ/DoHSpeedTest / calculateSpeedStats

Function calculateSpeedStats

script.js:624–634  ·  view source on GitHub ↗
(results)

Source from the content-addressed store, hash-verified

622}
623
624function calculateSpeedStats(results) {
625 if (!results.length) {
626 return { min: 'Unavailable', median: 'Unavailable', max: 'Unavailable', avg: 'Unavailable' };
627 }
628 const sorted = [...results].sort((a, b) => a - b);
629 const sum = sorted.reduce((acc, v) => acc + v, 0);
630 const avg = sum / sorted.length;
631 const mid = Math.floor(sorted.length / 2);
632 const median = sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
633 return { min: sorted[0], median, max: sorted[sorted.length - 1], avg };
634}
635
636function buildReliabilityProfile(speedResults, totalQueries) {
637 if (totalQueries === 0) {

Callers 1

performDNSTestsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected