Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Benchmark

Aggregator for performance results of various tests.

Hierarchy

  • Benchmark

Index

Constructors

Properties

data: BenchmarkData = {}

Raw data collected from Benchmark.record.

events: BenchmarkEventEmitter = ...

Event emitter.

Refer to BenchmarkEventEmitter.on for the event callback signatures.

Accessors

Methods

  • Find the measurement that meets some criteria. In the case of a tie, the first one found wins.

    Parameters

    • criteria: Criteria

      Criteria by which to select a measurement.

    • value: (m: Measurement) => number = ...

      Callback to select a specific field of each measurement for comparison. The default uses the mean plus the margin of error.

    Returns null | Measurement

    the matching measurement, or null if no measurements have been taken

  • incorporate(description: string[], measurement: Measurement): void
  • Add a measurement directly to Benchmark.data.

    Parameters

    • description: string[]

      Name of what is being tested. Must not be empty.

    • measurement: Measurement

      Measurement to add to the benchmark data.

    Returns void

  • Measure the time it takes for a function to execute. In addition to returning the measurement itself, this method also stores the result in Benchmark.data for later use/reporting.

    With this overload, since no description is provided, the data will not be recorded directly. However, a record event will still be emitted, allowing any listeners (such as reporters) to act on it.

    Parameters

    • fn: () => any

      Function to measure. If it returns a promise, then it will be awaited automatically as part of the iteration.

        • (): any
        • Returns any

    • Optional options: Partial<Omit<MeasureOptions, "verify">>

      Options to customize the measurement.

    Returns Promise<Measurement>

  • Measure the time it takes for a function to execute. In addition to returning the measurement itself, this method also stores the result in Benchmark.data for later use/reporting, and Benchmark.events emits a record event for any listeners.

    Parameters

    • description: string | string[]

      Name of what is being tested. This can be a series of names for nested categories. Must not be empty.

    • fn: () => any

      Function to measure. If it returns a promise, then it will be awaited automatically as part of the iteration.

        • (): any
        • Returns any

    • Optional options: Partial<Omit<MeasureOptions, "verify">>

      Options to customize the measurement.

    Returns Promise<Measurement>

  • report(): string
  • Create a report of all the benchmark results.

    Returns string

Generated using TypeDoc