tinybench - v6.1.6
    Preparing search index...

    Interface BenchLike

    Used to decouple Bench and Task

    interface BenchLike {
        addEventListener: <K extends BenchEvents>(
            type: K,
            listener:
                | EventListener<K, "bench">
                | EventListenerObject<K, "bench">
                | null,
            options?: boolean | AddEventListenerOptions,
        ) => void & (
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | AddEventListenerOptions,
        ) => void;
        concurrency: Concurrency;
        iterations: number;
        now: NowFn;
        removeEventListener: <K extends BenchEvents>(
            type: K,
            listener:
                | EventListener<K, "bench">
                | EventListenerObject<K, "bench">
                | null,
            options?: boolean | EventListenerOptions,
        ) => void & (
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | EventListenerOptions,
        ) => void;
        retainSamples: boolean;
        runtime: JSRuntime;
        runtimeVersion: string;
        setup: (task: Task, mode: HookMode) => void | Promise<void>;
        signal?: AbortSignal;
        teardown: (task: Task, mode: HookMode) => void | Promise<void>;
        threshold: number;
        throws: boolean;
        time: number;
        timerOverhead?: number;
        timestampProvider: TimestampProvider;
        warmup: boolean;
        warmupIterations: number;
        warmupTime: number;
        dispatchEvent(event: Event): boolean;
    }

    Hierarchy

    • EventTarget
      • BenchLike

    Implemented by

    Index
    addEventListener: <K extends BenchEvents>(
        type: K,
        listener:
            | EventListener<K, "bench">
            | EventListenerObject<K, "bench">
            | null,
        options?: boolean | AddEventListenerOptions,
    ) => void & (
        type: string,
        callback: EventListenerOrEventListenerObject | null,
        options?: boolean | AddEventListenerOptions,
    ) => void

    Adds a listener for the specified event type.

    Type Declaration

      • <K extends BenchEvents>(
            type: K,
            listener:
                | EventListener<K, "bench">
                | EventListenerObject<K, "bench">
                | null,
            options?: boolean | AddEventListenerOptions,
        ): void
      • Type Parameters

        Parameters

        Returns void

      • (
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | AddEventListenerOptions,
        ): void
      • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

        MDN Reference

        Parameters

        • type: string
        • callback: EventListenerOrEventListenerObject | null
        • Optionaloptions: boolean | AddEventListenerOptions

        Returns void

    concurrency: Concurrency

    Executes tasks concurrently based on the specified concurrency mode, if set.

    • When mode is set to null (default), concurrency is disabled.
    • When mode is set to 'task', each task's iterations (calls of a task function) run concurrently.
    • When mode is set to 'bench', different tasks within the bench run concurrently.
    iterations: number

    The amount of executions per task.

    now: NowFn

    A function to get a timestamp.

    removeEventListener: <K extends BenchEvents>(
        type: K,
        listener:
            | EventListener<K, "bench">
            | EventListenerObject<K, "bench">
            | null,
        options?: boolean | EventListenerOptions,
    ) => void & (
        type: string,
        callback: EventListenerOrEventListenerObject | null,
        options?: boolean | EventListenerOptions,
    ) => void

    Removes a previously registered event listener.

    Type Declaration

      • (
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | EventListenerOptions,
        ): void
      • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

        MDN Reference

        Parameters

        • type: string
        • callback: EventListenerOrEventListenerObject | null
        • Optionaloptions: boolean | EventListenerOptions

        Returns void

    retainSamples: boolean

    Should samples be retained for further custom processing

    runtime: JSRuntime

    The JavaScript runtime environment.

    runtimeVersion: string

    The JavaScript runtime version.

    setup: (task: Task, mode: HookMode) => void | Promise<void>

    A setup function that runs before each task execution.

    signal?: AbortSignal

    An AbortSignal to cancel the benchmark

    teardown: (task: Task, mode: HookMode) => void | Promise<void>

    A teardown function that runs after each task execution.

    threshold: number

    The maximum number of concurrent tasks to run

    throws: boolean

    Whether to throw an error if a task function throws

    time: number

    The amount of time to run each task.

    timerOverhead?: number

    The estimated cost of one timestamp provider call in milliseconds.

    Calibrated once at construction; undefined (or omitted) when timer overhead subtraction is disabled or unsupported by the implementation.

    timestampProvider: TimestampProvider

    The timestamp provider used by the benchmark.

    warmup: boolean

    Whether to warmup the tasks before running them

    warmupIterations: number

    The amount of warmup iterations per task.

    warmupTime: number

    The amount of time to warmup each task.

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean