forked from dapplion/benchmark
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add statistical convergence and outlier detection (#26)
* Fix few spellings * Simplify the creation of benchmark fn * Fix the error when undefined was shown in the logs * Show the pending tasks * Add some benchmark error cases to test manually * Refactor the convergence logic * Remove unused comment * Add CV convergence logic * Add cli option for convergence * Add unit tests for the math utilities * Add cli option for outlier cleanup averge * Add more comments * Add doc comments for convergence
- Loading branch information
1 parent
1f36c5c
commit 7efbd6f
Showing
14 changed files
with
691 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {BenchmarkOpts} from "../types.js"; | ||
|
||
export const defaultBenchmarkOptions: Required<BenchmarkOpts> = { | ||
minRuns: 1, | ||
maxRuns: Infinity, | ||
minMs: 100, | ||
maxMs: Infinity, | ||
maxWarmUpRuns: 1000, | ||
maxWarmUpMs: 500, | ||
convergeFactor: 0.5 / 100, // 0.5% | ||
runsFactor: 1, | ||
yieldEventLoopAfterEach: false, | ||
timeoutBench: 10_000, | ||
noThreshold: false, | ||
triggerGC: false, | ||
setupFiles: [], | ||
skip: false, | ||
only: false, | ||
threshold: 2, | ||
convergence: "linear", | ||
averageCalculation: "simple", | ||
}; | ||
|
||
export function getBenchmarkOptionsWithDefaults(opts: BenchmarkOpts): Required<BenchmarkOpts> { | ||
const options = Object.assign({}, defaultBenchmarkOptions, opts); | ||
|
||
if (options.noThreshold) { | ||
options.threshold = Infinity; | ||
} | ||
|
||
if (options.maxMs && options.maxMs > options.timeoutBench) { | ||
options.timeoutBench = options.maxMs * 1.5; | ||
} | ||
|
||
if (options.minMs && options.minMs > options.timeoutBench) { | ||
options.timeoutBench = options.minMs * 1.5; | ||
} | ||
|
||
return options; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.