Stopwatch Class
Stopwatch is a simple performance timer.
Stopwatch.startNew()
Create and start a stopwatch.
let stopwatch = Stopwatch.startNew();
sleep(500);
console.log(stopwatch.getElapsedMilliseconds());start()
Control the timer.
stopwatch.reset();
stopwatch.start();
sleep(300);
console.log(stopwatch.getElapsedMilliseconds());stop()
Control the timer.
sleep(300);
stopwatch.stop();
console.log(stopwatch.getElapsedMilliseconds());reset()
Control the timer.
stopwatch.reset();
console.log(stopwatch.getElapsedMilliseconds());restart()
Control the timer.
stopwatch.restart();
sleep(250);
console.log(stopwatch.getElapsedMilliseconds());getElapsedMilliseconds()
Read elapsed time.
sleep(250);
console.log(stopwatch.getElapsedMilliseconds());getElapsedSeconds()
Read elapsed time.
sleep(1200);
console.log(stopwatch.getElapsedSeconds());getElapsedMinutes()
Read elapsed time.
console.log(stopwatch.getElapsedMinutes());getElapsedNanoseconds()
Read elapsed time.
console.log(stopwatch.getElapsedNanoseconds());getElapsed()
Return a TimeSpan.
console.log(stopwatch.getElapsed().toSimpleString());isRunning()
Running state.
console.log(stopwatch.isRunning());toString()
Elapsed time as a formatted string.
let stopwatch = Stopwatch.startNew();
let result = stopwatch.toString();
console.log(result);