#[derive(Debug, Clone, Copy)]
pub struct Instant {
#[cfg(not(target_arch = "wasm32"))]
inner: std::time::Instant,
}
impl Instant {
#[inline]
pub fn now() -> Self {
Self {
#[cfg(not(target_arch = "wasm32"))]
inner: std::time::Instant::now(),
}
}
#[inline]
pub fn elapsed_secs_f64(&self) -> f64 {
#[cfg(not(target_arch = "wasm32"))]
{
self.inner.elapsed().as_secs_f64()
}
#[cfg(target_arch = "wasm32")]
{
0.0
}
}
#[inline]
pub fn elapsed_ms(&self) -> f64 {
self.elapsed_secs_f64() * 1000.0
}
#[inline]
pub fn elapsed_millis(&self) -> u128 {
#[cfg(not(target_arch = "wasm32"))]
{
self.inner.elapsed().as_millis()
}
#[cfg(target_arch = "wasm32")]
{
0
}
}
}