Skip to content

Stopwatch

1 min read

Import: import system;

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

Stopwatch

A high-resolution timer for measuring elapsed time, useful for benchmarking.

public class Stopwatch

constructor

Creates a new Stopwatch and starts measuring time immediately.

public constructor()

is_running

True while the stopwatch is currently accumulating time.

public get is_running(): bool

start

Starts or resumes measuring elapsed time.

public fun start(): void

stop

Stops measuring elapsed time.

public fun stop(): void

reset

Stops measuring elapsed time and resets the elapsed time to zero.

public fun reset(): void

restart

Stops measuring, resets the elapsed time to zero, and starts measuring again.

public fun restart(): void

elapsed_nanos

The total elapsed time measured by the current instance, in nanoseconds.

public get elapsed_nanos(): long

elapsed_ms

The total elapsed time measured by the current instance, in milliseconds.

public get elapsed_ms(): long