Skip to content

Commit

Permalink
bug: fix the timer of the benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
0oyun committed Aug 28, 2024
1 parent 065169f commit 4dca26b
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 746 deletions.
20 changes: 14 additions & 6 deletions halo2-base/src/utils/testing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Utilities for testing
use std::time::Duration;

use crate::{
gates::{
circuit::{builder::RangeCircuitBuilder, BaseCircuitParams, CircuitBuilderStage},
Expand All @@ -22,7 +24,7 @@ use crate::{
},
Context,
};
use ark_std::{end_timer, perf_trace::TimerInfo, start_timer};
use ark_std::{end_timer, start_timer};
use rand::{rngs::StdRng, SeedableRng};

use super::fs::gen_srs;
Expand Down Expand Up @@ -223,9 +225,12 @@ impl BaseTester {
let vk_time = start_timer!(|| "Generating vkey");
let vk = keygen_vk(&params, &builder).unwrap();
end_timer!(vk_time);
let vk_duration = vk_time.time.elapsed();

let pk_time = start_timer!(|| "Generating pkey");
let pk = keygen_pk(&params, vk, &builder).unwrap();
end_timer!(pk_time);
let pk_duration = pk_time.time.elapsed();

let break_points = builder.break_points();
drop(builder);
Expand All @@ -236,14 +241,17 @@ impl BaseTester {
f(builder.pool(0), &range, logic_input);
let proof = gen_proof(&params, &pk, builder);
end_timer!(proof_time);
let proof_duration = proof_time.time.elapsed();

let proof_size = proof.len();

let verify_time = start_timer!(|| "Verify time");
let verify_start_time = std::time::Instant::now();
check_proof(&params, pk.get_vk(), &proof, self.expect_satisfied);
let verify_duration = verify_start_time.elapsed();
end_timer!(verify_time);

BenchStats { config_params, vk_time, pk_time, proof_time, proof_size, verify_time }
BenchStats { config_params, vk_time: vk_duration, pk_time: pk_duration, proof_time: proof_duration, proof_size, verify_time: verify_duration }
}
}

Expand All @@ -252,13 +260,13 @@ pub struct BenchStats {
/// Config params
pub config_params: BaseCircuitParams,
/// Vkey gen time
pub vk_time: TimerInfo,
pub vk_time: Duration,
/// Pkey gen time
pub pk_time: TimerInfo,
pub pk_time: Duration,
/// Proving time
pub proof_time: TimerInfo,
pub proof_time: Duration,
/// Proof size in bytes
pub proof_size: usize,
/// Verify time
pub verify_time: TimerInfo,
pub verify_time: Duration,
}
4 changes: 2 additions & 2 deletions halo2-ecc/src/bn254/tests/combine_bls_mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ fn bench_merkle_tree() -> Result<(), Box<dyn std::error::Error>> {
bench_params.num_limbs,
bench_params.num_aggregation,
bench_params.num_origin,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed(),
stats.verify_time,
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/bn254/tests/ec_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ fn bench_ec_add() -> Result<(), Box<dyn std::error::Error>> {
bench_params.limb_bits,
bench_params.num_limbs,
bench_params.batch_size,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed()
stats.verify_time
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/bn254/tests/fixed_base_msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ fn bench_fixed_base_msm() -> Result<(), Box<dyn std::error::Error>> {
bench_params.limb_bits,
bench_params.num_limbs,
bench_params.batch_size,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed()
stats.verify_time,
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/bn254/tests/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ fn bench_merkle_tree() -> Result<(), Box<dyn std::error::Error>> {
bench_params.num_limbs,
bench_params.num_aggregation,
bench_params.num_origin,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed(),
stats.verify_time,
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/bn254/tests/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ fn bench_msm() -> Result<(), Box<dyn std::error::Error>> {
bench_params.num_limbs,
bench_params.batch_size,
bench_params.window_bits,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed(),
stats.verify_time,
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/bn254/tests/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ fn bench_pairing() -> Result<(), Box<dyn std::error::Error>> {
bench_params.lookup_bits,
bench_params.limb_bits,
bench_params.num_limbs,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed()
stats.verify_time,
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/secp256k1/tests/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ fn bench_secp256k1_ecdsa() -> Result<(), Box<dyn std::error::Error>> {
bench_params.lookup_bits,
bench_params.limb_bits,
bench_params.num_limbs,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed()
stats.verify_time,
)?;
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/secp256k1/tests/schnorr_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ fn bench_secp256k1_schnorr() -> Result<(), Box<dyn std::error::Error>> {
bench_params.lookup_bits,
bench_params.limb_bits,
bench_params.num_limbs,
stats.proof_time.time.elapsed(),
stats.proof_time,
stats.proof_size,
stats.verify_time.time.elapsed()
stats.verify_time,
)?;
}
Ok(())
Expand Down
125 changes: 0 additions & 125 deletions result.txt

This file was deleted.

Loading

0 comments on commit 4dca26b

Please sign in to comment.