MCPcopy Index your code
hub / github.com/nodejs/node / calculateStats

Function calculateStats

benchmark/calibrate-n.js:79–93  ·  view source on GitHub ↗
(values)

Source from the content-addressed store, hash-verified

77}
78
79function calculateStats(values) {
80 const mean = values.reduce((sum, val) => sum + val, 0) / values.length;
81
82 const squaredDiffs = values.map((val) => {
83 const diff = val - mean;
84 const squared = diff ** 2;
85 return squared;
86 });
87
88 const variance = squaredDiffs.reduce((sum, val) => sum + val, 0) / values.length;
89 const stdDev = Math.sqrt(variance);
90 const cv = stdDev / mean;
91
92 return { mean, stdDev, cv, variance };
93}
94
95function runBenchmark(n) {
96 return new Promise((resolve, reject) => {

Callers 1

mainFunction · 0.85

Calls 2

reduceMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…