Skip to content

Time: add time_ns() and sleep_ms() to stdlib#1122

Open
mbouaziz wants to merge 2 commits intomainfrom
stdlib-time-ns-sleep-ms
Open

Time: add time_ns() and sleep_ms() to stdlib#1122
mbouaziz wants to merge 2 commits intomainfrom
stdlib-time-ns-sleep-ms

Conversation

@mbouaziz
Copy link
Contributor

Summary

  • Add Time.time_ns(): nanosecond-precision monotonic clock (steady_clock) for elapsed time measurement
  • Add Time.sleep_ms(ms): sleep for a given number of milliseconds
  • Both are @debug-annotated and have 64-bit (native) and 32-bit (WASM fallback) implementations

Test plan

  • skargo test passes (49/49)
  • testTimeNs: verifies positive value and monotonicity
  • testSleepMs: verifies 1ms sleep takes between 1ms and 10ms

🤖 Generated with Claude Code

@mbouaziz mbouaziz requested a review from beauby February 27, 2026 17:58
mbouaziz and others added 2 commits February 27, 2026 21:36
time_ns() returns nanoseconds from a monotonic clock (steady_clock on 64-bit,
fallback to time_ms * 1e6 on 32-bit/WASM). sleep_ms() sleeps for the given
number of milliseconds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mbouaziz mbouaziz force-pushed the stdlib-time-ns-sleep-ms branch from a6cb4e9 to a82d81c Compare February 27, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant