From df183ae6dfabc6bbf1d9efadeb827ab6d9f01da0 Mon Sep 17 00:00:00 2001 From: Vivek Pandya Date: Mon, 22 Jan 2024 19:21:42 +0530 Subject: [PATCH] Use web_time crate instead of std::time --- plonky2/Cargo.toml | 3 ++- plonky2/src/fri/reduction_strategies.rs | 4 ++-- plonky2/src/util/timing.rs | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plonky2/Cargo.toml b/plonky2/Cargo.toml index d2727853b8..4cc44cccd3 100644 --- a/plonky2/Cargo.toml +++ b/plonky2/Cargo.toml @@ -15,7 +15,7 @@ default = ["gate_testing", "parallel", "rand_chacha", "std", "timing"] gate_testing = [] parallel = ["hashbrown/rayon", "plonky2_maybe_rayon/parallel"] std = ["anyhow/std", "rand/std", "itertools/use_std"] -timing = ["std"] +timing = ["std", "dep:web-time"] [dependencies] ahash = { version = "0.8.3", default-features = false, features = ["compile-time-rng"] } # NOTE: Be sure to keep this version the same as the dependency in `hashbrown`. @@ -34,6 +34,7 @@ serde = { version = "1.0", default-features = false, features = ["derive", "rc"] serde_json = "1.0" static_assertions = { version = "1.1.0", default-features = false } unroll = { version = "0.1.5", default-features = false } +web-time = { version = "1.0.0", optional = true } [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] getrandom = { version = "0.2", default-features = false, features = ["js"] } diff --git a/plonky2/src/fri/reduction_strategies.rs b/plonky2/src/fri/reduction_strategies.rs index df273eea11..6e5752296e 100644 --- a/plonky2/src/fri/reduction_strategies.rs +++ b/plonky2/src/fri/reduction_strategies.rs @@ -1,10 +1,10 @@ use alloc::vec; use alloc::vec::Vec; -#[cfg(feature = "timing")] -use std::time::Instant; use log::debug; use serde::Serialize; +#[cfg(feature = "timing")] +use web_time::Instant; /// A method for deciding what arity to use at each reduction layer. #[derive(Debug, Clone, Eq, PartialEq, Serialize)] diff --git a/plonky2/src/util/timing.rs b/plonky2/src/util/timing.rs index faa7442738..0ab721be52 100644 --- a/plonky2/src/util/timing.rs +++ b/plonky2/src/util/timing.rs @@ -1,7 +1,6 @@ -#[cfg(feature = "timing")] -use std::time::{Duration, Instant}; - use log::{log, Level}; +#[cfg(feature = "timing")] +use web_time::{Duration, Instant}; /// The hierarchy of scopes, and the time consumed by each one. Useful for profiling. #[cfg(feature = "timing")]