This module implements cross-platform system timer with milliseconds resolution.
Timer supports two types of clocks: system uses the most fast OS primitive to obtain wall clock time. mono uses monotonic clock time (default).
system clock is affected by discontinuous jumps in the system time. This clock is significantly faster then mono clock in most of the cases.
mono clock is not affected by discontinuous jumps in the system time. This clock is slower then system clock.
You can specify which timer you want to use -d:asyncTimer=<system/mono>.
Consts
asyncTimer {.strdefine.} = "mono"
- Source Edit
InfiniteDuration = (value: 9223372036854775807)
- Source Edit
Microsecond = (value: 1000)
- Source Edit
Millisecond = (value: 1000000)
- Source Edit
Nanosecond = (value: 1)
- Source Edit
ZeroDuration = (value: 0)
- Source Edit
Procs
func `+`(a: Duration; b: Duration): Duration {.inline, ...raises: [], tags: [], forbids: [].}
- Duration + Duration = Duration Source Edit
func `-`(a, b: Moment): Duration {.inline, ...raises: [], tags: [], forbids: [].}
-
Moment - Moment = Duration
Note: Duration can't be negative.
Source Edit func days(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to days. Source Edit
func days(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with days value v. Source Edit
func epochNanoSeconds(moment: Moment): int64 {....raises: [], tags: [], forbids: [].}
- Source Edit
func epochSeconds(moment: Moment): int64 {....raises: [], tags: [], forbids: [].}
- Source Edit
proc fastEpochTime(): uint64 {.inline, ...deprecated: "Use Moment.now()", raises: [], tags: [], forbids: [].}
- Procedure's resolution is millisecond. Source Edit
func hours(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to hours. Source Edit
func hours(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with hours value v. Source Edit
func isInfinite(a: Duration): bool {.inline, ...raises: [], tags: [], forbids: [].}
- Returns true if Duration a is infinite. Source Edit
func micros(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Source Edit
func microseconds(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to microseconds. Source Edit
func microseconds(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with microseconds value v. Source Edit
func millis(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Source Edit
func milliseconds(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to milliseconds. Source Edit
func milliseconds(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with milliseconds value v. Source Edit
func minutes(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to minutes. Source Edit
func minutes(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with minutes value v. Source Edit
func nanos(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Source Edit
func nanoseconds(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to nanoseconds. Source Edit
func nanoseconds(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with nanoseconds value v. Source Edit
func seconds(v: Duration): int64 {.inline, ...raises: [], tags: [], forbids: [].}
- Round Duration v to seconds. Source Edit
func seconds(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with seconds value v. Source Edit
func secs(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Source Edit
func toString(a: timer.Duration; parts = int.high): string {....raises: [], tags: [], forbids: [].}
- Returns a pretty string representation of Duration a - the number of parts returned can be limited thus truncating the output to an approximation that grows more precise as the duration becomes smaller Source Edit