shape-runtime 0.3.2

Bytecode compiler, builtins, and runtime infrastructure for Shape
Documentation
/// @module std::core::time
/// Precision Timing Utilities
///
/// Monotonic timing, wall-clock timestamps, sleep, and benchmarking.
///
/// # Example
///
/// ```shape
/// use std::core::time
///
/// let start = time.now()
/// // ... do work ...
/// let ms = time.millis()
/// print(f"Epoch millis: {ms}")
/// ```

/// Return the current monotonic instant for measuring elapsed time.
///
/// # Returns
///
/// An `Instant` value. Call `.elapsed()` to measure duration.
pub builtin fn now() -> _;

/// Sleep for the specified number of milliseconds (async).
///
/// # Arguments
///
/// * `ms` - Duration in milliseconds
pub builtin fn sleep(ms: float) -> _;

/// Sleep for the specified number of milliseconds (blocking).
///
/// # Arguments
///
/// * `ms` - Duration in milliseconds
pub builtin fn sleep_sync(ms: float) -> _;

/// Benchmark a function over N iterations, returning timing statistics.
///
/// # Arguments
///
/// * `callback` - Function to benchmark
/// * `iterations` - Number of iterations (default: 1000)
///
/// # Returns
///
/// Object with `elapsed_ms`, `iterations`, and `avg_ms` fields.
pub builtin fn benchmark(callback: _, iterations: int) -> _;

/// Start a stopwatch (returns an Instant). Call `.elapsed()` to read.
///
/// # Returns
///
/// An `Instant` value.
pub builtin fn stopwatch() -> _;

/// Return current wall-clock time as milliseconds since Unix epoch.
///
/// # Returns
///
/// Milliseconds since Unix epoch as a number.
pub builtin fn millis() -> float;