Creates a new (Suite:class).
import { Suite } from '@jonahsnider/benchmark';
const suite = new Suite('concatenation', { warmup: { durationMs: 10_000 }, run: { durationMs: 10_000 } });
Suites that specify a filepath can be run in a separate thread in a (Benchmark:class).
import { Suite } from '@jonahsnider/benchmark';
const suite = new Suite('concatenation', {
warmup: { durationMs: 10_000 },
run: { durationMs: 10_000 },
filepath: import.meta.url
});
The name of the (Suite:class)
Options for the (Suite:class)
Readonly
nameThe name of the (Suite:class)
Readonly
optionsOptions for running this (Suite:class) and its warmup.
The tests in this (Suite:class).
This (Suite:class)'s filepath, if it was provided. Used for running the (Suite:class) in a separate thread.
Adds a test to this (Suite:class).
const test = new Test(() => 'a' + 'b');
suite.addTest('+', test);
this
The name of the test
The test to add
Creates and adds a test to this (Suite:class).
suite.addTest('+', () => 'a' + 'b');
this
The name of the test
The function to run
Runs this (Suite:class) using (Suite:class).options.
const results = await suite.run();
Using an AbortSignal
to cancel the suite:
const ac = new AbortController();
const signal = ac.signal;
suite
.run(signal)
.then(console.log)
.catch(error => {
if (error.name === 'AbortError') {
console.log('The suite was aborted');
}
});
ac.abort();
The results of running this (Suite:class)
Optional
abortSignal: AbortSignalGenerated using TypeDoc
A collection of (Test:class)s that are different implementations of the same thing (ex. different ways of sorting an array).
Example