std/time

The std/time module provides utilities for high-precision time measurement and thread suspension.

Overview

Usage

import "std/time.zc"
import "std/io.zc"

fn main() {
    let start = Time::now();
    
    // Sleep for 1.5 seconds
    Time::sleep(Duration::from_ms(1500));
    
    let end = Time::now();
    println(f"Elapsed: {end - start} ms");
}

Struct Definitions

Duration

Represents a span of time.

struct Duration {
    millis: U64;
}

Time

Static utility struct for system time operations.

struct Time {}

Methods

Duration Methods

MethodSignatureDescription
from_msDuration::from_ms(ms: U64) -> DurationCreates a Duration from a count of milliseconds.
from_secsDuration::from_secs(s: U64) -> DurationCreates a Duration from a count of seconds.

Time Static Methods

MethodSignatureDescription
nowTime::now() -> U64Returns current system time in milliseconds since the epoch.
sleepTime::sleep(d: Duration)Suspends the current thread for the specified Duration.
sleep_msTime::sleep_ms(ms: U64)Suspends the current thread for the specified count of milliseconds.