From 2e4272e3a1a52987b9833893c755236ced73c03e Mon Sep 17 00:00:00 2001 From: Daniel Varga Date: Wed, 20 Jul 2022 02:44:19 +0200 Subject: [PATCH] Fix scaling factor for `window.performance.now` in WASM (#72) --- CHANGELOG.md | 1 + src/clocks/monotonic/wasm.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5ac9be..1ce0781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Changed - Fixed build issue on x86/x86_64 platforms that did not have SSE. +- Fixed clock off by a factor of 1000 in wasm/web browser ## [0.10.0] - 2022-05-18 diff --git a/src/clocks/monotonic/wasm.rs b/src/clocks/monotonic/wasm.rs index 1c41ee5..24db95f 100644 --- a/src/clocks/monotonic/wasm.rs +++ b/src/clocks/monotonic/wasm.rs @@ -13,7 +13,7 @@ impl Monotonic { .expect(WASM_MISSING_WINDOW_PERF) .now(); // `window.performance.now()` returns the time in milliseconds. - return f64::trunc(now * 1000.0) as u64; + return f64::trunc(now * 1_000_000.0) as u64; } }