UNPKG

@compas/cli

Version:

CLI containing utilities and simple script runner

68 lines (67 loc) 1.81 kB
/** * Mutate the global areBenchRunning * * @param {boolean} running */ export function setAreBenchRunning(running: boolean): void; /** * Set the bench logger * * @param {import("@compas/stdlib").Logger} logger */ export function setBenchLogger(logger: import("@compas/stdlib").Logger): void; /** * The argument passed to benchmark functions * * @typedef {object} BenchRunner * @property {number} N Amount of iterations this call should do * @property {() => void} resetTime Reset the start time. Should be used if some setup is * necessary, but shouldn't be counted to wards the time spent. */ /** * @typedef {(b: BenchRunner) => (void|Promise<void>)} BenchCallback */ /** * @typedef {object} BenchState * @property {string} name * @property {number} N * @property {string} operationTimeNs * @property {Array<number>} executionTimesNs * @property {BenchCallback} callback * @property {Error|undefined} [caughtException] */ /** * @type {import("@compas/stdlib").Logger} */ export let benchLogger: import("@compas/stdlib").Logger; /** * @type {boolean} */ export let areBenchRunning: boolean; /** * @type {Array<BenchState>} */ export const state: Array<BenchState>; /** * The argument passed to benchmark functions */ export type BenchRunner = { /** * Amount of iterations this call should do */ N: number; /** * Reset the start time. Should be used if some setup is * necessary, but shouldn't be counted to wards the time spent. */ resetTime: () => void; }; export type BenchCallback = (b: BenchRunner) => (void | Promise<void>); export type BenchState = { name: string; N: number; operationTimeNs: string; executionTimesNs: Array<number>; callback: BenchCallback; caughtException?: Error | undefined; };