//#region src/bench/types.d.ts /** * Measurement decisions made once by a pilot block and replayed verbatim by * every later block, so all blocks of a bench do identical work. */ interface BlockPlan { batch: boolean; batch_samples: number; batch_unroll: number; /** Untrimmed sample count the pilot collected and each block replays. */ samples: number; } interface Stats { debug: string; ticks: number; samples: number[]; counters?: any; kind: 'fn' | 'iter' | 'yield'; min: number; max: number; avg: number; p25: number; p50: number; p75: number; p99: number; p999: number; /** Per sample forced collection time above the process's fixed collection cost. */ gc?: { min: number; max: number; p50: number; }; /** Bytes allocated per iteration, including external memory such as typed array stores. */ heap?: { min: number; max: number; p50: number; }; /** Decisions this measurement made, usable to freeze later blocks. */ plan?: BlockPlan; /** Output compared with the baseline. */ snapshot?: Snapshot; /** Per-block summaries when the benchmark ran in multiple fresh processes. */ blocks?: { medians: number[]; /** Software calibration rates. The `freqs` name is retained for saved-result compatibility. */ freqs: number[]; /** Relative spread of each block's own samples, the within-process noise. */ spreads?: number[]; }; } /** * Numeric output kept as values so compare can apply a tolerance, with * non-finite numbers spelled out for JSON. Any other output is a digest. */ type Snapshot = string | number | Snapshot[]; type GeneratorBench = (state: any) => Generator; type GcMode = boolean | 'once' | 'inner'; interface Run { stats?: Stats; error?: unknown; name: string; args: Record; } interface Trial { runs: Run[]; alias: string; group: number; gcMode: GcMode; baseline: boolean; args: Record; kind: 'args' | 'static' | 'multi-args'; style: { compact: boolean; highlight: false | string; }; } //#endregion //#region src/bench/main.d.ts declare class B { f: ((...args: any[]) => any) | null; _args: Record; _name: string; _group: number; _gc: boolean; flags: number; _highlight: string | false; constructor(name: string, gen: GeneratorBench); constructor(name: string, fn: (...args: any[]) => any); name(name: string, color?: string | false): this; gc(gc?: boolean): this; highlight(color?: string | false): this; compact(bool?: boolean): this; baseline(bool?: boolean): this; range(name: string, s: number, e: number, m?: number): this; dense_range(name: string, s: number, e: number, a?: number): this; args(name: any, args?: any): this; _names(): Generator; run(thrw?: boolean, _tune?: any, plans?: Array): Promise; } //#endregion //#region src/assert.d.ts /** Error type used for failed benchmark checks. */ declare class AssertionError extends Error { actual: unknown; expected: unknown; constructor(message: string, actual?: unknown, expected?: unknown); } interface Assert { (condition: unknown, message?: string): asserts condition; /** Deep structural equality using the same serialization as snapshot digests. */ equal(actual: unknown, expected: unknown, message?: string): void; } declare const assert: Assert; //#endregion //#region src/config.d.ts interface LabsConfig { /** Directory to search for bench files, relative to the config file. */ benchDir: string; /** Glob pattern for bench file discovery. @default "**\/*.bench.ts" */ benchMatch: string; /** Node.js CLI flags passed when running each bench worker. */ nodeFlags: string[]; /** Directory for saved results and baseline pointer, relative to config file. @default ".labs" */ resultsDir: string; /** * Time budget per block in seconds. Every block runs at least this long and * collects at least `minSamples`. @default 0.5 */ blockTime?: number; /** Minimum samples per block. @default 20 */ minSamples?: number; /** Mann-Whitney U significance level. @default 0.05 */ alpha: number; /** Minimum |Hodges-Lehmann delta| required to flag a verdict. Filters environmental noise on identical code. @default 0.05 */ minDelta: number; /** * Relative tolerance for numeric snapshots with an absolute floor at one. * @default 1e-9 */ snapshotTolerance: number; /** * Fresh-process blocks per bench for saved runs. Each block is a new V8, so * between-block spread captures JIT nondeterminism and environment drift * that a single process hides. Override per run with `--blocks`. @default 8 */ blocks?: number; } declare function defineConfig(config: Partial & Pick): LabsConfig; //#endregion //#region src/index.d.ts declare function getBenchRegistry(): Array<{ groupName: string; alias: string; }>; declare function bench(gen: GeneratorBench): B; declare function bench(name: string, gen: GeneratorBench): B; declare function bench(fn: () => any): B; declare function bench(name: string, fn: () => any): B; declare function group(f: () => any): void; declare function group(name: string, f: () => any): void; //#endregion export { AssertionError, type LabsConfig, assert, bench, defineConfig, getBenchRegistry, group };