diff --git a/src/modes/terminal.ts b/src/modes/terminal.ts index 73fac3a..4b51fbc 100644 --- a/src/modes/terminal.ts +++ b/src/modes/terminal.ts @@ -16,17 +16,17 @@ let benchmarkStart: Either<[null, Noop]> = null; let benchmarkEnd: Either<[null, Noop]> = null; /** - * Listens to events and prints suite and benchmark results into a terminal. - * - * @example - * ```ts - * // subscribe to events - * await useTerminal(); - * - * // run suite which publishes data to the events - * await runBenchmarks(); - * ``` -* */ + * Listens to events and prints suite and benchmark results into a terminal. + * + * @example + * ```ts + * // subscribe to events + * await useTerminal(); + * + * // run suite which publishes data to the events + * await runBenchmarks(); + * ``` + * */ export async function useTerminal() { let results: { name: string; cpu: Offset; ram: Offset }[] = []; let longestBenchmarkName = 0; @@ -98,9 +98,13 @@ export async function useTerminal() { const cpuSecondaryInfo = gray( `[-${cpuMin}, +${cpuMax}]% (${cpuCycles} cycles)`, ); - const cpuTime = gray(`(${cpu.median < 1_000_000 - ? `${cpu.median.toLocaleString()} ns` - : `${(cpu.median / 1_000_000).toPrecision(3)} ms`})`); + const cpuTime = gray( + `(${ + cpu.median < 1_000_000 + ? `${cpu.median.toLocaleString()} ns` + : `${(cpu.median / 1_000_000).toPrecision(3)} ms` + })`, + ); const ramSecondaryInfo = gray( `[-${ramMin}, +${ramMax}]% (${ramCycles} cycles)`, ); diff --git a/src/offset/getOffset.ts b/src/offset/getOffset.ts index f387e4d..b337c75 100644 --- a/src/offset/getOffset.ts +++ b/src/offset/getOffset.ts @@ -1,9 +1,4 @@ -import { - FN_ASYNC, - FN_SYNC, - OFFSET, - OFFSETS, -} from "../constants"; +import { FN_ASYNC, FN_SYNC, OFFSET, OFFSETS } from "../constants"; import { stats } from "../stats"; import { Name, TypeMode } from "../types"; diff --git a/src/preset.ts b/src/preset.ts index e797a25..cf0fcbd 100644 --- a/src/preset.ts +++ b/src/preset.ts @@ -14,72 +14,72 @@ import { import { pub } from "ueve/async"; /** - * Creates a suite preset with the provided options - * - * @example - * - * ```ts - * const suite = preset({ - * // options - * }); - * ``` - * - * These are the default options: - * - * ```ts - * { - * cpu: { - * chunkSize: 100, - * compareSize: 10, - * rangePercent: 10, - * }, - * ram: { - * chunkSize: 5, - * compareSize: 5, - * rangePercent: 5, - * }, - * offset: { - * allow: true, - * rangePercent: 5, - * }, - * gc: { - * allow: true, - * } - * } - * ``` -* */ + * Creates a suite preset with the provided options + * + * @example + * + * ```ts + * const suite = preset({ + * // options + * }); + * ``` + * + * These are the default options: + * + * ```ts + * { + * cpu: { + * chunkSize: 100, + * compareSize: 10, + * rangePercent: 10, + * }, + * ram: { + * chunkSize: 5, + * compareSize: 5, + * rangePercent: 5, + * }, + * offset: { + * allow: true, + * rangePercent: 5, + * }, + * gc: { + * allow: true, + * } + * } + * ``` + * */ export function createPreset(partialOptions?: DeepPartial) { const options = getOptions(partialOptions); const stores = createStores(options); /** - * Creates a named suite with an object of benchmarks - * - * Usually you get this `suite` function from calling `preset` with options. - * But if you want just a suite with default options then you can import - * `suite` function directly from the library. - * - * @example - * - * ```ts - * const firstSuite = suite("Name", { - * // benchmarks - * }); - * ``` - * - * Since all suites share the same references to internal objects you - * should never run multiple suites at the same time (not awaiting them). - * - * This is how multiple suites should be run: - * - * @example - * - * ```ts - * await firstSuite(); - * await secondSuite(); - * await thirdSuite(); - * ``` - * */ + * Creates a named suite with an object of benchmarks + * + * Usually you get this `suite` function from calling `preset` with options. + * But if you want just a suite with default options then you can import + * `suite` function directly from the library. + * + * @example + * + * ```ts + * const firstSuite = suite("Name", { + * // benchmarks + * }); + * ``` + * + * Since all suites share the same references to internal objects you + * should never run multiple suites at the same time (not awaiting them). + * + * This is how multiple suites should be run: + * + * @example + * + * ```ts + * await firstSuite(); + * await secondSuite(); + * await thirdSuite(); + * ``` + * */ return function createSuite<$Benchmarks extends Benchmarks>( suiteName: string, benchmarks: $Benchmarks, @@ -87,15 +87,15 @@ export function createPreset(partialOptions?: DeepPartial) { const suite = [Symbol(), suiteName] as Name; /** - * Collects stats for the previously defined benchmarks - * and triggers lifecycle events with the appropriate data. - * - * @example - * - * ```ts - * await firstSuite(); - * ``` - * */ + * Collects stats for the previously defined benchmarks + * and triggers lifecycle events with the appropriate data. + * + * @example + * + * ```ts + * await firstSuite(); + * ``` + * */ return async function runSuite() { await pub($suiteBefore, { suite, benchmarks: Object.keys(benchmarks) }); diff --git a/src/run.ts b/src/run.ts index 1476c4c..20c3713 100644 --- a/src/run.ts +++ b/src/run.ts @@ -4,20 +4,20 @@ import { $benchmarkAfterEach, $benchmarkBeforeEach } from "./events"; import { Name, RunData } from "./types"; /** - * @internal - * - * Runs cpu-async/cpu-sync/ram-async/ram-sync benchmark - * and triggers $benchmarkBeforeAll/$benchmarkAfterAll events. - * - * @example - * - * ```ts - * await run(benchmarkName, { - * benchmark, - * mode: "cpu", - * type: "async", - * }); -* */ + * @internal + * + * Runs cpu-async/cpu-sync/ram-async/ram-sync benchmark + * and triggers $benchmarkBeforeAll/$benchmarkAfterAll events. + * + * @example + * + * ```ts + * await run(benchmarkName, { + * benchmark, + * mode: "cpu", + * type: "async", + * }); + * */ export async function run(name: Name, { benchmark, mode, type }: RunData) { const isAsync = type === "async"; const store = GLOBAL.stores[mode].chunk; diff --git a/src/stats.ts b/src/stats.ts index c16917c..4fc6a49 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -4,18 +4,18 @@ import { run } from "./run"; import { Benchmark, Mode, Name, Offsets } from "./types"; /** - * @internal - * - * Runs benchmark in a loop until the difference between - * the maximum and minimum values of the last N values - * is less than the specified percentage. - * - * @example - * - * ```ts - * await stats(benchmarkName, benchmark, "cpu", offsets); - * ``` -* */ + * @internal + * + * Runs benchmark in a loop until the difference between + * the maximum and minimum values of the last N values + * is less than the specified percentage. + * + * @example + * + * ```ts + * await stats(benchmarkName, benchmark, "cpu", offsets); + * ``` + * */ export async function stats( name: Name, benchmark: Benchmark,