Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Suite

node.js benchmark Suite

Events:

  • cycle - emits with { test: PerfTest, result: PerfResult } on completion of each test
  • complete - emits with PerfResult[] after all tests are done

Hierarchy

  • EventEmitter
    • Suite

Index

Constructors

constructor

Properties

Private results

results: PerfResult[]

Private tests

tests: PerfTest[]

Static defaultMaxListeners

defaultMaxListeners: number

Methods

add

  • add(name: string, func: Function): this
  • Add a test for benchmark to the Suite

    Parameters

    • name: string

      name of test

    • func: Function

      function to call

    Returns this

    this

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

Protected estimatePerf

  • estimatePerf(test: PerfTest, isAsync: boolean, limitTime?: number): Promise<{ count: number; estimated: number; time: number }>
  • Do a rough estimate on number of times test can run per second

    Parameters

    • test: PerfTest

      test to estimate

    • isAsync: boolean

      async function

    • Default value limitTime: number = 0.15

      how long to run estimate

    Returns Promise<{ count: number; estimated: number; time: number }>

    estimate result

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

Protected measureExecTime

  • measureExecTime(func: Function, isAsync: boolean, count: number): Promise<number>
  • Measure time takes to execute function count times

    Parameters

    • func: Function

      function to call

    • isAsync: boolean

      is function async (will await on it)

    • count: number

      number of times to call

    Returns Promise<number>

    time in seconds

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

run

  • run(): Promise<{ name: string; perSecCount: number; time: number; totalCount: number }[]>
  • Run benchmark on all tests

    Returns Promise<{ name: string; perSecCount: number; time: number; totalCount: number }[]>

    results - sorted from fastest to slowest

runTest

  • runTest(test: PerfTest, isAsync: boolean): Promise<{ name: string; perSecCount: number; time: number; totalCount: number }>
  • Run benchmark on a test

    Parameters

    • test: PerfTest

      test to run

    • isAsync: boolean

      test should be async

    Returns Promise<{ name: string; perSecCount: number; time: number; totalCount: number }>

    test benchmark result

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc