UNPKG

iso-bench

Version:

Small benchmark library focused in avoiding optimization/deoptimization pollution between tests by isolating them.

40 lines (39 loc) 1.09 kB
import { AsyncCallback, AsyncSetupCallback, IsoBenchOptions, Processor } from "."; export type Sample = { cycles: number; time: number; ops: number; }; export type TestOptions = { samplesPerSpawn?: number; spawns?: number; } & ({ customCycles: number; } | { customCycles?: null; time?: number; }); export type TestCallbackSetup<T> = { async: false; callback: (setupData: T) => void; setup?: (() => T) | null; } | { async: true; callback: AsyncCallback | AsyncSetupCallback<T>; setup?: (() => T) | null; }; export declare class Test { readonly name: string; readonly index: number; readonly options: Required<TestOptions>; private _cb; error: string | null; opMs: number; totalTime: number; samples: Sample[]; group: string; constructor(name: string, index: number, options: Required<TestOptions>, _cb: TestCallbackSetup<unknown>); fork(benchName: string, processors: Processor[], options: Required<IsoBenchOptions>): Promise<void>; setGroup(name: string): void; run(): Promise<void>; }