toofast
Version:
The Node.js performance testing tool with unit-test-like API.
61 lines (60 loc) • 2.33 kB
TypeScript
export interface TestOptions {
/**
* Maximum measure duration. Doesn't include the duration of warmup iterations.
*
* @default 10_000
*/
measureTimeout?: number;
/**
* The maximum relative margin of error that must be reached for each measurement [0, 1].
*
* @default 0.002
*/
targetRme?: number;
/**
* The maximum number of warmup iterations that are run before each measurement.
*
* @default 1
*/
warmupIterationCount?: number;
/**
* The maximum number of iterations in a batch.
*
* @default Infinity
*/
batchIterationCount?: number;
/**
* The maximum duration of batched measurements.
*
* @default 1_000
*/
batchTimeout?: number;
/**
* The delay between batched measurements. VM is expected to run garbage collector during this delay.
*
* @default 200
*/
batchIntermissionTimeout?: number;
}
export interface MeasureOptions extends TestOptions {
afterWarmup?: HookCallback;
beforeBatch?: HookCallback;
afterBatch?: HookCallback;
beforeIteration?: HookCallback;
afterIteration?: HookCallback;
}
export type HookCallback = () => PromiseLike<void> | void;
export declare function beforeEach(hook: HookCallback): void;
export declare function afterEach(hook: HookCallback): void;
export declare function beforeWarmup(hook: HookCallback): void;
export declare function afterWarmup(hook: HookCallback): void;
export declare function beforeBatch(hook: HookCallback): void;
export declare function afterBatch(hook: HookCallback): void;
export declare function beforeIteration(hook: HookCallback): void;
export declare function afterIteration(hook: HookCallback): void;
export declare function describe(name: string, callback: () => PromiseLike<void> | void): void;
export declare function describe(name: string, options: TestOptions, callback: () => PromiseLike<void> | void): void;
export declare function test(name: string, callback: () => PromiseLike<void> | void): void;
export declare function test(name: string, options: TestOptions, callback: () => PromiseLike<void> | void): void;
export declare function measure(callback: () => unknown): void;
export declare function measure(options: MeasureOptions, callback: () => unknown): void;