#[cfg(not(target_arch = "wasm32"))]
mod inner {
use std::time::{Duration, Instant};
#[derive(Debug, Clone, Copy)]
pub struct Timer(Instant);
impl Timer {
pub fn now() -> Self {
Timer(Instant::now())
}
pub fn elapsed(&self) -> Duration {
self.0.elapsed()
}
pub fn elapsed_ms(&self) -> u64 {
self.0.elapsed().as_millis() as u64
}
}
}
#[cfg(target_arch = "wasm32")]
mod inner {
use std::time::Duration;
#[derive(Debug, Clone, Copy)]
pub struct Timer;
impl Timer {
pub fn now() -> Self {
Timer
}
pub fn elapsed(&self) -> Duration {
Duration::ZERO
}
pub fn elapsed_ms(&self) -> u64 {
0
}
}
}
pub use inner::Timer;