The Benchmark instance for keeping track of the benchmark tasks and controlling them.

Hierarchy

Constructors

  • Parameters

    Returns BenchFactory

Properties

_tasks: Map<string, BenchTask>
_todos: Map<string, BenchTask>
iterations: number
now: (() => number)

Type declaration

    • (): number
    • Returns number

setup: Hook
signal?: AbortSignal
teardown: Hook
throws: boolean
time: number
warmupIterations: number
warmupTime: number

Accessors

  • get results(): (undefined | BenchTaskResult)[]
  • (getter) tasks results as an array

    Returns (undefined | BenchTaskResult)[]

  • get tasks(): BenchTask[]
  • (getter) tasks as an array

    Returns BenchTask[]

  • get todos(): BenchTask[]
  • Returns BenchTask[]

Methods

  • add a benchmark task to the task map

    Parameters

    • name: string
    • fn: Fn
    • Optional opts: FnOptions

    Returns this

  • Type Parameters

    • K extends BenchEvents

    • T = BenchEventsMap[K]

    Parameters

    • type: K
    • listener: T
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    Returns boolean

  • get a task based on the task name

    Parameters

    • name: string

    Returns undefined | BenchTask

  • remove a benchmark task from the task map

    Parameters

    • name: string

    Returns this

  • Type Parameters

    • K extends BenchEvents

    • T = BenchEventsMap[K]

    Parameters

    • type: K
    • listener: T
    • Optional options: boolean | EventListenerOptions

    Returns void

  • reset each task and remove its result

    Returns void

  • run the added tasks that were registered using the add method. Note: This method does not do any warmup. Call warmup for that.

    Returns Promise<BenchTask[]>

  • table of the tasks results

    Returns (null | {
        Average Time (ns): string | number;
        Margin: string;
        Samples: string | number;
        Task Name: string;
        ops/sec: string;
    })[]

  • add a benchmark todo to the todo map

    Parameters

    • name: string
    • Optional fn: Fn
    • Optional opts: FnOptions

    Returns this

  • warmup the benchmark tasks. This is not run by default by the run method.

    Returns Promise<void>

Generated using TypeDoc