@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 reuseProperties
elapsed
readonlyelapsed:number
Total elapsed time in milliseconds (excluding paused time)
running
readonlyrunning:boolean
Whether the stopwatch is running
startTime
readonlystartTime: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