Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

feat: add endAtRME option to end when rme drops below threshold #223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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: 16 additions & 0 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@
elapsed = 0,
initCount = bench.initCount,
minSamples = bench.minSamples,
endAtRME = bench.endAtRME,
queue = [],
sample = bench.stats.sample;

Expand Down Expand Up @@ -1935,6 +1936,11 @@
'variance': variance
});

// Exit early if we have reached a satisfying answer
if (size >= minSamples && rme < endAtRME) {
maxedOut = true;
}

// Abort the cycle loop when the minimum sample size has been collected
// and the elapsed time exceeds the maximum time allowed per benchmark.
// We don't count cycle delays toward the max time because delays may be
Expand Down Expand Up @@ -2208,6 +2214,16 @@
*/
'minTime': 0,

/**
* Exit the benchmark early if relative margin of error drops below
* this number. The benchmark will still adhere to the minSamples
* option.
*
* @memberOf Benchmark.options
* @type number
*/
'endAtRME': 0,

/**
* The name of the benchmark.
*
Expand Down