Skip to main content

Class: Stopwatch

Stopwatch class, uses native node to replicate/extend performance-now dependency.

Constructors

new Stopwatch()

new Stopwatch(digits: number): Stopwatch

Starts a new stopwatch

Parameters

ParameterTypeDefault value
digitsnumber2

Returns

Stopwatch

Source

index.ts:23

Properties

#end

private #end: null | number

The end time of this stopwatch

Source

index.ts:18


#start

private #start: number

The start time of this stopwatch

Source

index.ts:13


digits

digits: number

The number of digits to appear after the decimal point when returning the friendly duration.

Source

index.ts:8

Accessors

duration

get duration(): number

The duration of this stopwatch since start or start to end if this stopwatch has stopped.

Returns

number

Source

index.ts:32


running

get running(): boolean

If the stopwatch is running or not.

Returns

boolean

Source

index.ts:39

Methods

reset()

reset(): this

Resets the Stopwatch to 0 duration (Returns a stopped state)

Returns

this

Source

index.ts:55


restart()

restart(): this

Restarts the stopwatch (Returns a running state)

Returns

this

Source

index.ts:46


start()

start(): this

Starts the Stopwatch

Returns

this

Source

index.ts:64


stop()

stop(): this

Stops the Stopwatch, freezing the duration

Returns

this

Source

index.ts:76


toString()

toString(): string

Defines toString behavior

Returns

string

Source

index.ts:84