Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Result

The result of benchmark.

This value will included outlier. Please use Result.dropOutlier if you want drop they.

Hierarchy

  • Result

Index

Constructors

constructor

  • new Result(name: string, msecs: number[]): Result
  • Parameters

    • name: string

      Name of benchmark.

    • msecs: number[]

      Times of benchmark result.

    Returns Result

Properties

Readonly msecs

msecs: number[]

Times of benchmark result in milliseconds.

Readonly name

name: string

Name of this test.

Accessors

average

  • get average(): number
  • Average time of this benchmark in milliseconds.

    Returns number

errorRange

  • get errorRange(): number
  • Guessed error range of this benchmark.

    Returns number

errorRate

  • get errorRate(): number

fastest

  • get fastest(): number
  • The time of fastest test in milliseconds.

    Returns number

opsPerSec

  • get opsPerSec(): number

sem

  • get sem(): number
  • Standard error of the mean of times.

    Returns number

slowest

  • get slowest(): number
  • The time of slowest test in milliseconds.

    Returns number

std

  • get std(): number

total

  • get total(): number
  • Total milliseconds of this benchmark.

    Returns number

variance

  • get variance(): number
  • Time unbiased sample variance of times.

    Returns number

Methods

assert

  • assert(...expected: (string | number)[]): void
  • Assertion if it taked more (or less) time than expected.

    Expected rule format is {operator}{number}{unit}; use like <=10msec. Operator and unit are can omit. If omitted, uses <= and msec.

    This function will throw AsyncMarkAssertionError if result is unaccepcable.

    since

    0.3.0

    Parameters

    • Rest ...expected: (string | number)[]

      Expected time in milliseconds number or string value. e.g. <10ms or >=20s.

    Returns void

    Supported operators

    example means
    "<42" faster than 42 msec
    "<=42" or omit 42 msec or faster
    ">42" slower than 42 msec
    ">=42" 42 msec or slower

    Supported units

    example means
    "42s" or "42sec" seconds
    "42ms" or "42msec" milliseconds
    "42us" or "42usec" microseconds
    "42ns" or "42nsec" nanoseconds

    Examples

    Simple usage

    const result = await Benchmark(function() {
        # do something that expect done in least 100msec
    }).run();
    
    result.assert(100);

    Combination rule

    const result = await Benchmark(async function() {
        await sleep_function(100);
    }).run();
    
    result.assert('>90ms', '<110ms');

dropOutlier

  • dropOutlier(threshold?: number): Result
  • Make new Result that droped outlier.

    Parameters

    • Default value threshold: number = 2

      The threshold of outlier testing.

    Returns Result

    New Result instance.

toString

  • toString(): string
  • Convert to string for printing.

    Returns string

    Human redable string

Generated using TypeDoc