Options
All
  • Public
  • Public/Protected
  • All
Menu

Tracks a function's execution in {@link (Test:class).histogram}.

example
import { Test } from '@jonahsnider/benchmark';

const test = new Test(() => 'a' + 'b');

Type parameters

  • T = unknown

Hierarchy

  • Test

Index

Constructors

Properties

Methods

Constructors

  • new Test<T>(implementation: () => T | PromiseLike<T>): Test<T>
  • Create a new {@link (Test:class)} with a given implementation.

    You probably don't want to instantiate this class directly, instead you can register tests with {@link (Suite:class).(addTest:2)}. You can also register {@link (Test:class)} instances with {@link (Suite:class).(addTest:1)}.

    example
    const test = new Test(() => 'a' + 'b');
    

    Type parameters

    • T = unknown

    Parameters

    • implementation: () => T | PromiseLike<T>

      The implementation function of the test

        • (): T | PromiseLike<T>
        • Returns T | PromiseLike<T>

    Returns Test<T>

Properties

histogram: RecordableHistogram = ...

Execution times for this {@link (Test:class)}'s implementation.

Methods

  • run(): Promise<T>
  • Runs this {@link (Test:class)}'s implementation once and records the execution time in {@link (Test:class).histogram}.

    Returns Promise<T>

    The return value of this {@link (Test:class)}'s implementation

Generated using TypeDoc