@dapplion/benchmark
Version:
Ensures that new code does not introduce performance regressions with CI. Tracks:
37 lines • 1.34 kB
TypeScript
import { BenchmarkOpts } from "../types.js";
import { BenchmarkRunOptsWithFn } from "./runBenchFn.js";
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
interface ItBenchFn {
<T, T2>(opts: BenchmarkRunOptsWithFn<T, T2>): void;
<T, T2>(idOrOpts: string | Omit<BenchmarkRunOptsWithFn<T, T2>, "fn">, fn: (arg: T) => void): void;
<T, T2>(idOrOpts: string | PartialBy<BenchmarkRunOptsWithFn<T, T2>, "fn">, fn?: (arg: T) => void | Promise<void>): void;
}
interface ItBench extends ItBenchFn {
only: ItBenchFn;
skip: ItBenchFn;
}
export declare const itBench: ItBench;
/**
* Customize benchmark opts for a describe block. Affects only tests within that Mocha.Suite
* ```ts
* describe("suite A1", function () {
* setBenchOpts({runs: 100});
* // 100 runs
* itBench("bench A1.1", function() {});
* itBench("bench A1.2", function() {});
* // 300 runs
* itBench({id: "bench A1.3", runs: 300}, function() {});
*
* // Supports nesting, child has priority over parent.
* // Arrow functions can be used, won't break it.
* describe("suite A2", () => {
* setBenchOpts({runs: 200});
* // 200 runs.
* itBench("bench A2.1", () => {});
* })
* })
* ```
*/
export declare function setBenchOpts(opts: BenchmarkOpts): void;
export {};
//# sourceMappingURL=index.d.ts.map