Skip to content

StopWatch

A stopwatch used for timing, capable of measuring time down to microseconds.

javascript
function StopWatchDemo() {
    let watch = new StopWatch();
    watch.Start();
    while(watch.elapsed < 1)
    {
    }
    watch.Stop();
    let elapsedSecond = watch.elapsed;
    watch.Restart();
    while(watch.elapsed < 1)
    {
    }
    elapsedSecond = watch.elapsed;
    let elapsedMs = watch.elapsedMs;
    let elapsedUs = watch.elapsedUs;
}

成员变量

StopWatch.elapsedUs : number
(Read Only) Returns the amount of time in microseconds that has elapsed since the stopwatch started.
StopWatch.elapsedMs : number
(Read Only) Returns the amount of time in milliseconds that has elapsed since the stopwatch started.
StopWatch.elapsed : number
(Read Only) Returns the amount of time in seconds that has passed since the stopwatch started.

成员方法

StopWatch.ructor ( val : IntPtr? ) : ructor(IntPtr?
StopWatch.Start ( ) : void
Starts the timer.
StopWatch.Stop ( ) : void
Stop the timer.
StopWatch.Restart ( ) : void
Restarts the timer.