Tracks a function's execution in (Test:class).histogram.

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

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

Type Parameters

  • T = unknown

Constructors

Properties

Methods

Constructors

  • Create a new (Test:class) with a given implementation.

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

    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>

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

Properties

histogram: RecordableHistogram = ...

Execution times for this (Test:class)'s implementation.

Methods

  • Runs this (Test:class)'s implementation once and records the execution time in (Test:class).histogram.

    Returns Promise<T>

    The return value of this (Test:class)'s implementation