Options
All
  • Public
  • Public/Protected
  • All
Menu

Helper to record the amount of time elapsed between 2 points during execution.

example
const stopwatch = new Stopwatch();

stopwatch.start();

const elapsed = stopwatch.end();
example
const stopwatch = Stopwatch.start();

const elapsed = stopwatch.end();

Hierarchy

  • Stopwatch

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

startTime?: bigint

Accessors

  • get started(): boolean
  • If this stopwatch was started at any some point. This will return true even if the stopwatch is stopped.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const stopwatch = new Stopwatch();
    console.log(stopwatch.started); // false

    stopwatch.start();
    console.log(stopwatch.started); // true

    Returns boolean

Methods

  • end(): number
  • Return the duration elapsed since the start.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const elapsed = stopwatch.end();
    

    Returns number

    The amount of time elapsed in milliseconds.

  • start(): void
  • Start recording the duration of this stopwatch.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    stopwatch.start();
    

    Returns void

  • Create a new stopwatch and start it.

    Time complexity: O(1)

    Space complexity: O(1)

    example
    const stopwatch = Stopwatch.start();
    

    Returns Stopwatch

Generated using TypeDoc