We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
window.performance.now() return milliseconds. As Instant is in nanoseconds, it needs to be multiplied by 1.000.000 not 1.000.
Example to demonstrate the problem:
#[wasm_bindgen] pub struct TestQuanta { last_time: quanta::Instant } #[wasm_bindgen] impl TestQuanta { #[wasm_bindgen(constructor)] pub fn new() -> Self { Self{last_time: quanta::Instant::now()} } #[wasm_bindgen(method)] pub fn time_since_last_call(&mut self) -> f64 { let now = quanta::Instant::now(); let elapsed = now.duration_since(self.last_time); self.last_time = now; elapsed.as_millis() as f64 } }
let test_quanta = new TestQuanta(); setInterval(() => console.log(`elapsed: ${test_quanta.time_since_last_call()}ms`), 3000);
Expected: log something around 3000ms, as interval is called every 3000ms.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
window.performance.now() return milliseconds. As Instant is in nanoseconds, it needs to be multiplied by 1.000.000 not 1.000.
Example to demonstrate the problem:
Expected: log something around 3000ms, as interval is called every 3000ms.
The text was updated successfully, but these errors were encountered: