Skip to content

Commit

Permalink
Add benchmarking on proof generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ekrembal committed Jan 8, 2024
1 parent 8dd5238 commit 7cccf2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions membership-proof/wasm-nova/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ crate-type = ["cdylib", "rlib"]

[dev-dependencies]
wasm-bindgen-test = "0.3.37"
web-sys = { version = "0.3", features = ["Performance"] }
13 changes: 12 additions & 1 deletion membership-proof/wasm-nova/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use wasm_bindgen_test::*;
use wasm_nova::wasm::{
generate_params, generate_proof, read_filem
};
use web_sys::window; // Import the window function


#[wasm_bindgen_test]
async fn ftest() {
Expand All @@ -16,6 +18,15 @@ async fn gtest() {
let pp = generate_params("output/proofOfInnocence.cbor", "http://127.0.0.1:8000").await;
let input_json_str = read_filem("output/inputs.json", "http://127.0.0.1:8000").await;
let start_json_str = read_filem("output/start.json", "http://127.0.0.1:8000").await;
// Start timing
let performance = window().expect("should have a Window").performance().expect("should have a Performance");
let start_time = performance.now();

generate_proof(pp, "output/proofOfInnocence.r1cs", "output/proofOfInnocence_js/proofOfInnocence.wasm", &input_json_str, &start_json_str, "http://127.0.0.1:8000").await;
}

// End timing
let end_time = performance.now();
let elapsed_time = end_time - start_time;
console_log!("Elapsed time: {} milliseconds", elapsed_time);

}

0 comments on commit 7cccf2a

Please sign in to comment.