TimeReferenceNew · 0.744
Stopwatch.new
Create a stopped stopwatch.
Details#
Creates a stopwatch with zero accumulated time and IsRunning = false. Call Start to begin measuring. ElapsedTime returns a Duration. Stopping preserves the elapsed total; starting again adds another interval. Reset clears the total and leaves the stopwatch stopped.
Fields Stopwatch#
| Field | Type | Meaning |
|---|---|---|
IsRunning | boolean | True while the stopwatch is running; false after construction, Stop or Reset. |
ElapsedTime | Duration | Accumulated elapsed time, including the current interval while running. Each read returns a duration value; read again for a fresh measurement. |
Signature#
Stopwatch.new(): StopwatchReturns#
A new, stopped Stopwatch with zero elapsed time.
Examples#
Local example
local watch = Stopwatch.new()
print(watch.IsRunning) -- false
watch:Start()
-- Perform your local work here.
watch:Stop()
print(watch.ElapsedTime.Milliseconds)Notes#
- ElapsedTime is a Duration: read .Seconds, .Milliseconds or another duration field. A saved ElapsedTime value does not update itself.