Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/operation-graph > Stopwatch

Stopwatch class

Represents a typical timer/stopwatch which keeps track of elapsed time in between two events.

Signature:

export declare class Stopwatch 

Constructors

Constructor

Modifiers

Description

(constructor)()

Constructs a new instance of the Stopwatch class

Properties

Property

Modifiers

Type

Description

duration

readonly

number

Get the duration in seconds.

endTime

readonly

number | undefined

Return the end time of the most recent stopwatch run.

isRunning

readonly

boolean

startTime

readonly

number | undefined

Return the start time of the most recent stopwatch run.

Methods

Method

Modifiers

Description

reset()

Resets all values of the stopwatch back to the original

start()

Starts the stopwatch. Note that if end() has been called, reset() should be called before calling start() again.

start()

static

Static helper function which creates a stopwatch which is immediately started

stop()

Stops executing the stopwatch and saves the current timestamp

toString()

Displays how long the stopwatch has been executing in a human readable format.