std.time Module Reference
The std.time module provides nanosecond-precision timestamps, wall clock access, and thread sleep execution.
time_example.sp
1import std.io;2import std.time;34fn main() -> void {5 let start = time.now();67 // Simulate short delay8 time.sleep(100); // 100 milliseconds910 let elapsed = time.now() - start;11 println("Elapsed time: ${elapsed} ms");12}
Exported Functions
time.now
Native Builtinfn time.now() -> int
Returns the current monotonic system timestamp in milliseconds.
Returns:
inttime.sleep
Native Builtinfn time.sleep(int milliseconds) -> void
Suspends execution of the current thread for the specified duration.
Parameters
milliseconds(int)
Delay in milliseconds.Returns:
void