Skip to content
New issue

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

Add wasm feature #114

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ julia = ["sdp", "dep:libc", "dep:num-derive", "serde", "faer-sparse"]
# enable a blas/lapack source package
python = ["sdp", "dep:libc", "dep:pyo3", "dep:num-derive", "serde", "faer-sparse"]

wasm = ["dep:web-time"]

#compile with faer supernodal solver option
faer-sparse = ["dep:faer", "dep:faer-entity"]
Expand Down Expand Up @@ -190,8 +191,17 @@ crate-type = ["lib","cdylib"]
rustdoc-args = [ "--html-in-header", "./html/rustdocs-header.html" ]
features = ["sdp","sdp-mkl"]

# ------------------------------
# wasm compatibility
# ------------------------------

[dependencies.web-time]
optional = true
version = "0.2.3"

# ------------------------------
# testing, benchmarking etc
# ------------------------------
[dev-dependencies]
tempfile = "3"
tempfile = "3"

11 changes: 10 additions & 1 deletion src/timers/timers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use std::time::{Duration, Instant};

cfg_if::cfg_if! {
if #[cfg(feature="wasm")] {
use web_time::{Duration, Instant};
}
else {
use std::time::{Duration, Instant};
}
}


#[derive(Debug, Default)]
struct InnerTimer {
Expand Down