Class Stopwatch

Stopwatch (French: chronomètre) to measure elapsed time.

Sections

SectionSummary
DebugDebugg and log functions.
DurationsClock and durations utility functions
  • Clock: measure elapsed time, time formating,
  • Conversions from/to milliseconds, note duration, percentage of note duration, 256th of quarter

Summary

Return typeFunction and summary
Stopwatchnew()
Instantiate and start a stopwatch
 reset()
Reset the stopwatch to zero.
stringstring(boolean exact, boolean clockFormat)
Return elapsed time as formatted string.
numbertime()
Return the elapsed time since stopwatch instantiation or last reset.

Methods

Stopwatch:new()

Instantiate and start a stopwatch

Return
Stopwatch: Stopwatch

Stopwatch:reset()

Reset the stopwatch to zero.

Stopwatch:time()

Return the elapsed time since stopwatch instantiation or last reset.

Return
number: Elapsed time in milliseconds.

Stopwatch:string(boolean exact, boolean clockFormat)

Return elapsed time as formatted string.

ParameterTypeDefaultDescription
exactbooleanfalseIf false, removes details (e.g. no milliseconds if time is minutes and you don't need so much precision).
clockFormatbooleanfalseClock format: returns 00:03.010 instead of 3s 10ms
Return
string: "10 ms", "3 s 456 ms", "1 min 14 s", 00:03.010...
See
string_time