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
| Name | Description |
|---|---|
!= | 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
| Name | Description |
|---|---|
| hours | Converts the duration to hours. |
| microseconds | Converts the duration to microseconds. |
| milliseconds | Converts the duration to milliseconds. |
| minutes | Converts the duration to minutes. |
| nanoseconds | Converts the duration to nanoseconds. |
| seconds | Converts the duration to seconds. |