writeonce/tests/corpus/run/time-ticks/fixture.wo
shoney.arickathil e51aeaa498 feat: time.ticks builtin — CLOCK_MONOTONIC us Int (id 84)
- iteration 22's honest clock: monotone, never wall time; time.now
  stays ms. One types.ml row, sysio case, explicit dispatch arm
  (sys range gate stops at PROC_RUN)
- corpus run/time-ticks (RED WO-E406 first); oop-e2e 104/0, full
  battery green; surface doc row (07-systems-stdlib absent, disclosed)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 16:13:10 +02:00

28 lines
597 B
Text

use time
-- time.ticks: CLOCK_MONOTONIC microseconds as Int. Values are machine
-- noise; the fixture asserts existence and ordering — a later reading
-- never precedes an earlier one, and a spin's elapsed is non-negative.
fn spin(rounds: Int) {
let i = 0;
while i < rounds {
i = i + 1;
}
}
fn main() -> Int {
let t0 = time.ticks();
spin(100000);
let t1 = time.ticks();
if t1 >= t0 {
print("ticks: monotone");
} else {
print("ticks: BACKWARDS ${t1 - t0}");
}
if t0 > 0 {
print("ticks: nonzero");
} else {
print("ticks: zero start");
}
return 0;
}