Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions lib/internal/bench_runner/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ const {
MathMin,
MathRound,
MathSqrt,
MathSumPrecise,
Number,
NumberIsFinite,
NumberMAX_SAFE_INTEGER,
ObjectFreeze,
ObjectKeys,
PromiseWithResolvers,
SafeArrayIterator,
SafeSet,
StringPrototypeToLowerCase,
} = primordials;
Expand Down Expand Up @@ -485,18 +487,6 @@ class BenchContext {
}
}

function arithmeticMean(values) {
let sum = 0;
let compensation = 0;
for (let i = 0; i < values.length; i++) {
const adjusted = values[i] - compensation;
const next = sum + adjusted;
compensation = (next - sum) - adjusted;
sum = next;
}
return sum / values.length;
}

function summarizeSamples(samples) {
const rates = [];
let min = Infinity;
Expand All @@ -508,7 +498,7 @@ function summarizeSamples(samples) {
max = MathMax(max, rate);
}

const mean = arithmeticMean(rates);
const mean = MathSumPrecise(new SafeArrayIterator(rates)) / rates.length;
let variance = 0;
for (let i = 0; i < rates.length; i++) {
const difference = rates[i] - mean;
Expand Down
Loading