@thi.ng/bench
Version:
Benchmarking & profiling utilities w/ various statistics & formatters (CSV, JSON, Markdown etc.)
19 lines • 748 B
TypeScript
import type { TimingResult } from "./api.js";
/**
* Executes given function `n` times, prints elapsed time to console and
* returns last result from fn. The optional `prefix` will be displayed
* with the output, allowing to label different measurements.
*
* @param fn - function to time
* @param n - number of iterations
*/
export declare const bench: <T>(fn: () => T, n?: number, prefix?: string) => T;
/**
* Similar to {@link bench}, but produces no output and instead returns
* tuple of `fn`'s last result and the grand total time measurement.
*
* @param fn - function to time
* @param n - number of iterations
*/
export declare const benchResult: <T>(fn: () => T, n?: number) => TimingResult<T>;
//# sourceMappingURL=bench.d.ts.map