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;
3
4fn main() -> void {
5 let start = time.now();
6
7 // Simulate short delay
8 time.sleep(100); // 100 milliseconds
9
10 let elapsed = time.now() - start;
11 println("Elapsed time: ${elapsed} ms");
12}

Exported Functions

time.now

Native Builtin
fn time.now() -> int

Returns the current monotonic system timestamp in milliseconds.

Returns:int

time.sleep

Native Builtin
fn time.sleep(int milliseconds) -> void

Suspends execution of the current thread for the specified duration.

Parameters
milliseconds(int)
Delay in milliseconds.
Returns:void