Module time_ops

Module time_ops 

Source
Expand description

Time operations for Seq

Provides timing primitives for performance measurement and delays.

§Usage from Seq

time.now      # ( -- Int ) microseconds since epoch
time.nanos    # ( -- Int ) nanoseconds (monotonic, for timing)
100 time.sleep-ms  # ( Int -- ) sleep for N milliseconds

§Example: Measuring execution time

: benchmark ( -- )
  time.nanos    # start time
  do-work
  time.nanos    # end time
  swap -        # elapsed nanos
  1000000 /     # convert to ms
  "Elapsed: " write
  int->string write
  "ms" write-line
;

Re-exports§

pub use patch_seq_time_nanos as time_nanos;
pub use patch_seq_time_now as time_now;
pub use patch_seq_time_sleep_ms as time_sleep_ms;

Functions§

patch_seq_time_nanos
Get monotonic nanoseconds for precise timing
patch_seq_time_now
Get current time in microseconds since Unix epoch
patch_seq_time_sleep_ms
Sleep for a specified number of milliseconds