Skip to content
FutureBlitz

    Install

    Import std.time.clock

    Stopwatch

    std.time.clock

    class

    Public Class Stopwatch

    Measures how long goes by while it runs, over as many starts and stops as it has.

    Examples

    Local start = Instant.FromNanoseconds(0)
    Local watch = Stopwatch.StartNew(start)
    Expect(watch.ElapsedAt(Instant.FromNanoseconds(1_500_000)) == 1500.Microseconds)
    watch.Stop(Instant.FromNanoseconds(2_000_000))
    Expect(watch.Elapsed == 2.Milliseconds && !watch.IsRunning)

    std/time/clock.fb, line 84

    • Public New() constructor #

      A Stopwatch at 0 that isn't running.

    • Public Static Method StartNew(): Stopwatch static method #

      A Stopwatch running from now, or from the Instant.

    • Public Static Method StartNew(now: Instant): Stopwatch static method #

      A Stopwatch running from now.

    • Public Property IsRunning: Bool property #

      Whether it's running.

    • Public Property Elapsed: Duration property #

      What it's measured, now or at the Instant.

    • Public Method ElapsedAt(now: Instant): Duration method #

      What it's measured at now.

    • Public Method Start() method #

      Starts it, now or at the Instant, unless it's running.

    • Public Method Start(now: Instant) method #

      Starts it at now, unless it's running.

    • Public Method Stop() method #

      Stops it, now or at the Instant, keeping what it measured, unless it's stopped.

    • Public Method Stop(now: Instant) method #

      Stops it at now, keeping what it measured, unless it's stopped.

    • Public Method Reset() method #

      Stops it at 0.

    • Public Method Restart() method #

      Starts it again from 0, now or at the Instant.

    • Public Method Restart(now: Instant) method #

      Starts it again from 0, at now.

    Report an issue with this page or with FutureBlitz on GitHub.