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 = "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): string {.inline, ...raises: [], tags: [].}
- Returns string representation of Duration a. Source Edit
func `$`(a: Moment): string {.inline, ...raises: [], tags: [].}
- Returns string representation of Moment a as nanoseconds value. Source Edit
func `*`(a: Duration; b: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Returns Duration multiplied by scalar integer. Source Edit
func `*`(a: SomeIntegerI64; b: Duration): Duration {.inline, ...raises: [].}
- Returns Duration multiplied by scalar integer. Source Edit
func `+=`(a: var Duration; b: Duration) {.inline, ...raises: [], tags: [].}
- Duration += Duration Source Edit
func `+=`(a: var Moment; b: Duration) {.inline, ...raises: [], tags: [].}
- Moment += Duration Source Edit
func `+`(a: Duration; b: Duration): Duration {.inline, ...raises: [], tags: [].}
- Duration + Duration = Duration Source Edit
func `+`(a: Duration; b: Moment): Moment {.inline, ...raises: [], tags: [].}
- Duration + Moment = Moment Source Edit
func `+`(a: Moment; b: Duration): Moment {.inline, ...raises: [], tags: [].}
- Moment + Duration = Moment Source Edit
func `-=`(a: var Duration; b: Duration) {.inline, ...raises: [], tags: [].}
- Duration -= Duration Source Edit
func `-=`(a: var Moment; b: Duration) {.inline, ...raises: [], tags: [].}
- Moment -= Duration Source Edit
func `-`(a, b: Moment): Duration {.inline, ...raises: [], tags: [].}
-
Moment - Moment = Duration
Note: Duration can't be negative.
Source Edit func `-`(a: Duration; b: Duration): Duration {.inline, ...raises: [], tags: [].}
-
Duration - Duration = Duration
Note: Duration can't be negative.
Source Edit func `-`(a: Moment; b: Duration): Moment {.inline, ...raises: [], tags: [].}
-
Moment - Duration = Moment
Note: Moment can be negative
Source Edit func `<=`(a, b: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if a less or equal b. Source Edit
func `<=`(a, b: Moment): bool {.inline, ...raises: [], tags: [].}
- Returns true if a less or equal b. Source Edit
func `<`(a, b: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if a less then b. Source Edit
func `<`(a, b: Moment): bool {.inline, ...raises: [], tags: [].}
- Returns true if a less then b. Source Edit
func `==`(a, b: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if a equal to b. Source Edit
func `==`(a, b: Moment): bool {.inline, ...raises: [], tags: [].}
- Returns true if a equal to b. Source Edit
func `>=`(a, b: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if a bigger or equal b. Source Edit
func `>=`(a, b: Moment): bool {.inline, ...raises: [], tags: [].}
- Returns true if a bigger or equal b. Source Edit
func `>`(a, b: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if a bigger then b. Source Edit
func `>`(a, b: Moment): bool {.inline, ...raises: [], tags: [].}
- Returns true if a bigger then b. Source Edit
func `div`(a: Duration; b: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Returns Duration which is result of dividing a Duration by scalar integer. Source Edit
func days(v: Duration): int64 {.inline, ...raises: [], tags: [].}
- 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: [].}
- Source Edit
func epochSeconds(moment: Moment): int64 {....raises: [], tags: [].}
- Source Edit
proc fastEpochTime(): uint64 {.inline, ...deprecated: "Use Moment.now()", raises: [], tags: [].}
- Source Edit Procedure's resolution is millisecond.
proc fromNow(t: typedesc[Moment]; a: Duration): Moment {.inline, ...raises: [].}
- Returns moment in time which is equal to current moment + Duration. Source Edit
func hours(v: Duration): int64 {.inline, ...raises: [], tags: [].}
- Round Duration v to hours. Source Edit
func hours(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with hours value v. Source Edit
func init(t: typedesc[Moment]; value: int64; precision: Duration): Moment {. ...raises: [].}
- Initialize Moment with absolute time value value with precision precision. Source Edit
func isInfinite(a: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if Duration a is infinite. Source Edit
func isZero(a: Duration): bool {.inline, ...raises: [], tags: [].}
- Returns true if Duration a is 0. Source Edit
func micros(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Source Edit
func microseconds(v: Duration): int64 {.inline, ...raises: [], tags: [].}
- 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: [].}
- 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: [].}
- 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: [].}
- Round Duration v to nanoseconds. Source Edit
func nanoseconds(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with nanoseconds value v. Source Edit
proc now(t: typedesc[Moment]): Moment {.inline, ...raises: [].}
- Returns current moment in time as Moment. Source Edit
func seconds(v: Duration): int64 {.inline, ...raises: [], tags: [].}
- 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: [].}
- 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
func weeks(v: Duration): int64 {.inline, ...raises: [], tags: [].}
- Round Duration v to weeks. Source Edit
func weeks(v: SomeIntegerI64): Duration {.inline, ...raises: [].}
- Initialize Duration with weeks value v. Source Edit