From 4fcec0f0ba71100ab089d5474a105d7b2f4cdcb1 Mon Sep 17 00:00:00 2001 From: Sergey Melnychuk Date: Wed, 30 Oct 2024 12:58:44 +0100 Subject: [PATCH] perf(wasm): log rpc calls latency --- Cargo.lock | 13 ++++++++++++- Cargo.toml | 1 + src/eth.rs | 4 +++- web/beerus-web/Cargo.lock | 11 +++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27d08e74..d872209e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -662,6 +662,7 @@ dependencies = [ "url", "validator", "web-sys", + "web-time", "wiremock", ] @@ -5570,7 +5571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a45489186a6123c128fdf6016183fcfab7113e1820eb813127e036e287233fb" dependencies = [ "jiff-tzdb-platform", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -10616,6 +10617,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki" version = "0.22.4" diff --git a/Cargo.toml b/Cargo.toml index 2cb8dc12..d55165dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ reqwest = { version = "0.12.3", default-features = false, features = ["json"] } gloo-timers = { version = "0.3.0", features = ["futures"] } web-sys = "0.3.69" +web-time = "1.1.0" [dev-dependencies] diff --git a/src/eth.rs b/src/eth.rs index 5b4235c5..83590790 100644 --- a/src/eth.rs +++ b/src/eth.rs @@ -1,6 +1,6 @@ use std::str::FromStr; #[cfg(target_arch = "wasm32")] -use std::time::Instant; +use web_time::Instant; use ethers::types::{Address, Bytes, SyncingStatus, H256}; use eyre::{Context, Result}; @@ -139,6 +139,7 @@ impl EthereumClient { web_sys::console::log_1( &format!("call to stateBlockNumber completed in {ms} ms").into(), ); + #[allow(unused_variables)] let now = Instant::now(); } @@ -152,6 +153,7 @@ impl EthereumClient { web_sys::console::log_1( &format!("call to stateBlockHash completed in {ms} ms").into(), ); + #[allow(unused_variables)] let now = Instant::now(); } diff --git a/web/beerus-web/Cargo.lock b/web/beerus-web/Cargo.lock index 9daa23f3..77575f97 100644 --- a/web/beerus-web/Cargo.lock +++ b/web/beerus-web/Cargo.lock @@ -431,6 +431,7 @@ dependencies = [ "url", "validator", "web-sys", + "web-time", ] [[package]] @@ -7139,6 +7140,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki" version = "0.22.4"