-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow benchmarking fft algorithms for javascript wasm targets
- Loading branch information
1 parent
8da0c7b
commit 55336ec
Showing
9 changed files
with
116 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Accessed by wasm-bindgen when testing for the wasm target | ||
[target.wasm32-unknown-unknown] | ||
runner = 'wasm-bindgen-test-runner' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! The standard API for Instant is not available in Wasm runtimes. | ||
//! This module replaces the Instant type from std to a custom implementation. | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
mod wasm; | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
pub(crate) use wasm::Instant; | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
pub(crate) use std::time::Instant; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pub(crate) struct Instant { | ||
start: f64, | ||
} | ||
|
||
impl Instant { | ||
/// This function only has a millisecond resolution on some platforms like the chrome browser | ||
pub fn now() -> Self { | ||
let now = js_sys::Date::new_0().get_time(); | ||
Self { start: now } | ||
} | ||
|
||
/// This function only has a millisecond resolution on some platforms like the chrome browser, | ||
/// which means it can easily return 0 when called on quick code | ||
pub fn elapsed(&self) -> core::time::Duration { | ||
let now = js_sys::Date::new_0().get_time(); | ||
core::time::Duration::from_millis((now - self.start) as u64) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters