UNPKG

@paulmillr/jsbt

Version:

JS Build Tools: build, benchmark, test libs and apps

53 lines (52 loc) 1.86 kB
/*! micro-bmark - MIT License (c) 2020 Paul Miller, 2010-2016 Mathias Bynens, John-David Dalton, Robert Kieffer from JSLitmus.js */ /** * Benchmark JS projects with nanosecond resolution. * * - Precise: 1ns resolution using `process.hrtime` * - Lightweight: ~200 lines of code, no dependencies - to not interfere with benchmarked code * - Readable: utilizes colors and nice units, shows rel. margin of error only if it's high * * @module */ export type BenchStats = { stats: { rme: number; min: number | bigint; max: number | bigint; mean: number | bigint; median: number | bigint; formatted: string; }; perSecStr: string; perSec: bigint; perItemStr: string; measurements: bigint[]; }; export type CbFn = (iter?: number) => {}; declare function setMaxRunTime(val: number): void; declare function logMem(): void; declare function formatDuration(duration: any): string; declare function calcDeviation<T extends number | bigint>(list: T[]): number; declare function calcCorrelation<T extends number | bigint>(x: T[], y: T[]): number; declare function calcStats<T extends number | bigint>(list: T[]): { rme: number; min: T; max: T; mean: any; median: T; formatted: string; }; declare function getTime(): bigint; declare function benchmarkRaw(callback: CbFn, samples?: number): Promise<BenchStats>; export declare function bench(label: string, fn: CbFn, samples?: number): Promise<BenchStats | undefined>; export default bench; export declare const utils: { getTime: typeof getTime; setMaxRunTime: typeof setMaxRunTime; logMem: typeof logMem; formatDuration: typeof formatDuration; calcStats: typeof calcStats; calcDeviation: typeof calcDeviation; calcCorrelation: typeof calcCorrelation; benchmarkRaw: typeof benchmarkRaw; };