Files
materialcraft/crates/eval/src/time.rs
T

11 lines
394 B
Rust

/// Milliseconds since the first call (0 on the web, where `std::time::Instant` is unavailable)
pub fn now_ms() -> f64 {
#[cfg(not(target_arch = "wasm32"))]
{
static START: std::sync::OnceLock<std::time::Instant> = std::sync::OnceLock::new();
START.get_or_init(std::time::Instant::now).elapsed().as_secs_f64() * 1000.0
}
#[cfg(target_arch = "wasm32")]
0.0
}