Skip to main content

TimerDuration

Represents a duration of time with nanosecond precision.

TimerDuration is used to represent elapsed time intervals. It supports arithmetic operations and can be converted to various time units like hours, minutes, seconds, milliseconds, microseconds, and nanoseconds. It provides high-precision timing measurements for performance analysis.

Example


var timer = Timer()
// ... do some work ...
var duration = timer.elapsed()
print("Elapsed: ${duration.milliseconds} ms")
print("Human readable: ${duration}")

Symbols

NameDescription
!=Performs inequality comparison operation.
+Performs addition operation.
+=Performs addition assignment operation.
-Performs subtraction operation.
-=Performs subtraction assignment operation.
<Performs less than comparison operation.
<=Performs less than or equal comparison operation.
=Assigns the value of the right-hand side to the left-hand side.
==Performs equality comparison operation.

Members

NameDescription
hoursConverts the duration to hours.
microsecondsConverts the duration to microseconds.
millisecondsConverts the duration to milliseconds.
minutesConverts the duration to minutes.
nanosecondsConverts the duration to nanoseconds.
secondsConverts the duration to seconds.