Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "bench"

Index

Functions

Const bench

  • bench<T>(fn: () => T, n?: number, prefix?: string): T
  • Executes given function n times, prints elapsed time to console and returns last result from fn. The optional prefix will be displayed with the output, allowing to label different measurements.

    Type parameters

    • T

    Parameters

    • fn: () => T

      function to time

        • (): T
        • Returns T

    • Default value n: number = 1000000

      number of iterations

    • Default value prefix: string = ""

    Returns T

Const benchResult

  • Similar to bench, but produces no output and instead returns tuple of fn's last result and the grand total time measurement.

    Type parameters

    • T

    Parameters

    • fn: () => T

      function to time

        • (): T
        • Returns T

    • Default value n: number = 1000000

      number of iterations

    Returns TimingResult<T>

Generated using TypeDoc