Function in clock compiler

mono_nanos

fn mono_nanos() -> int
Import
use clock::{mono_nanos};
Source: compiler/src/builtin_docs/clock.hy

Returns monotonic nanoseconds from a process-local starting point.

The value never goes backwards and is unrelated to wall time: only the difference between two readings means something.

Returns#

int

Examples#

use clock::{mono_nanos, sleep_ms};
use tests::assert;
let start = mono_nanos();
sleep_ms(5);
let elapsed_ms = (mono_nanos() - start) / 1000000;
assert!(elapsed_ms >= 5);

See also#

  • wall_nanos: Returns the current wall-clock time in nanoseconds since the Unix epoch (UTC).
  • sleep_ms: Pauses for at least ms milliseconds.
↑ ↓ navigate ↵ open