mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-30 18:13:53 +01:00
11 lines
394 B
Rust
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
|
|
}
|