Skip to content

@web-engine-dev/time


@web-engine-dev/time / Stopwatch

Interface: Stopwatch

Stopwatch for measuring elapsed time

Example

typescript
const sw: Stopwatch = createStopwatch();
sw.start();
doExpensiveWork();
sw.stop();
console.log(`Work took ${sw.elapsedSeconds()}s`);
sw.reset(); // Ready for reuse

Properties

elapsed

readonly elapsed: number

Total elapsed time in milliseconds (excluding paused time)


running

readonly running: boolean

Whether the stopwatch is running


startTime

readonly startTime: number

Start time in milliseconds

Methods

elapsedSeconds()

elapsedSeconds(): number

Get elapsed time in seconds

Returns

number


reset()

reset(): void

Reset the stopwatch

Returns

void


start()

start(): void

Start or resume the stopwatch

Returns

void


stop()

stop(): void

Stop/pause the stopwatch

Returns

void

Proprietary software. All rights reserved.