Skip to content

Commit deb923a

Browse files
committed
Replace instant with web-time
- swap the cross-platform timer dependency to web-time - remove instant-specific wasm feature wiring - update optimizer timing call sites to use web_time::Instant - keep existing native and wasm timing behavior without stdweb risk - completely remove wasm
1 parent 1276f5b commit deb923a

4 files changed

Lines changed: 6 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ num = "0.4"
8282
# Our own stuff - L-BFGS: limited-memory BFGS directions
8383
lbfgs = "0.3"
8484

85-
# Instant is a generic timer that works on Wasm (with wasm-bindgen)
86-
instant = { version = "0.1" }
85+
# Cross-platform time primitives with WebAssembly support
86+
web-time = "1"
8787

88-
# Wasm-bindgen is only activated if OpEn is compiled with `--features wasm`
89-
wasm-bindgen = { version = "0.2", optional = true }
9088

9189
# sc-allocator provides an implementation of a bump allocator
9290
rpmalloc = { version = "0.2", features = [
@@ -116,9 +114,6 @@ jem = ["jemallocator"]
116114
# RPMalloc
117115
rp = ["rpmalloc"]
118116

119-
# WebAssembly
120-
wasm = ["wasm-bindgen", "instant/wasm-bindgen", "instant/inaccurate"]
121-
122117
# --------------------------------------------------------------------------
123118
# T.E.S.T. D.E.P.E.N.D.E.N.C.I.E.S
124119
# --------------------------------------------------------------------------

src/alm/alm_optimizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ where
914914
pub fn solve(&mut self, u: &mut [f64]) -> Result<AlmOptimizerStatus, SolverError> {
915915
let mut num_outer_iterations = 0;
916916
// let tic = std::time::Instant::now();
917-
let tic = instant::Instant::now();
917+
let tic = web_time::Instant::now();
918918
let mut exit_status = ExitStatus::Converged;
919919
self.alm_cache.reset(); // first, reset the cache
920920
self.alm_cache.available_time = self.max_duration;

src/core/fbs/fbs_optimizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where
9999
ConstraintType: constraints::Constraint + 'life,
100100
{
101101
fn solve(&mut self, u: &mut [f64]) -> Result<SolverStatus, SolverError> {
102-
let now = instant::Instant::now();
102+
let now = web_time::Instant::now();
103103

104104
// Initialize - propagate error upstream, if any
105105
self.fbs_engine.init(u)?;

src/core/panoc/panoc_optimizer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ where
123123
ConstraintType: constraints::Constraint + 'life,
124124
{
125125
fn solve(&mut self, u: &mut [f64]) -> Result<SolverStatus, SolverError> {
126-
let now = instant::Instant::now();
126+
let now = web_time::Instant::now();
127127

128128
/*
129129
* Initialise [call panoc_engine.init()]
@@ -218,7 +218,7 @@ mod tests {
218218
let mut panoc_cache = PANOCCache::new(n_dimension, tolerance, lbfgs_memory);
219219
let problem = Problem::new(&bounds, cost_gradient, cost_function);
220220
let mut panoc = PANOCOptimizer::new(problem, &mut panoc_cache).with_max_iter(max_iters);
221-
let now = instant::Instant::now();
221+
let now = web_time::Instant::now();
222222
let status = panoc.solve(&mut u_solution).unwrap();
223223

224224
println!("{} iterations", status.iterations());

0 commit comments

Comments
 (0)