code cleaning and building/running script modified with rust flags for faster run

This commit is contained in:
Manish Kumar 2024-07-31 22:55:58 +05:30
parent c0429fa765
commit 568aca520e
4 changed files with 25 additions and 16 deletions

View File

@ -4,5 +4,7 @@
rustup override set nightly rustup override set nightly
# Build # Build
cargo build # RUSTFLAGS=-Ctarget-cpu=native cargo build
RUSTFLAGS=-Ctarget-cpu=native cargo build --release --bin plonky2_hash_benchmarks

View File

@ -12,4 +12,4 @@ echo "HASH = $ZKBENCH_HASH_TYPE"
echo "Input Size (Bytes) = $ZKBENCH_INPUT_SIZE_BYTES" echo "Input Size (Bytes) = $ZKBENCH_INPUT_SIZE_BYTES"
# Run the benchmarks # Run the benchmarks
./target/debug/plonky2_hash_benchmarks $ZKBENCH_HASH_TYPE $ZKBENCH_INPUT_SIZE_BYTES ./target/release/plonky2_hash_benchmarks $ZKBENCH_HASH_TYPE $ZKBENCH_INPUT_SIZE_BYTES

View File

@ -251,23 +251,28 @@ pub fn keccak_bench(size: usize) -> Result<()>{
for i in 0..256 { for i in 0..256 {
pw.set_bool_target(output_t[i], exptected_output_bits[i]); pw.set_bool_target(output_t[i], exptected_output_bits[i]);
} }
let circuit_size = builder.num_gates();
println!("circuit size: {:?}", builder.num_gates());
let data = builder.build::<C>(); let data = builder.build::<C>();
let now = Instant::now();
let proof = data.prove(pw)?;
println!("time = {:?}", now.elapsed()); let (proof_generation_time, proof) = {
println!( let now = Instant::now();
"degree = {}, degree_bits= {}", let proof = data.prove(pw)?;
data.common.degree(), (now.elapsed(), proof)
data.common.degree_bits() };
); let proof_size = proof.to_bytes().len();
let (verification_time, verification_result) = {
data.verify(proof)?; let now = Instant::now();
Ok(()) let res = data.verify(proof);
(now.elapsed(), res)
};
eprintln!("circuit size: {}", circuit_size);
eprintln!("proof generation time: {:?}", proof_generation_time);
eprintln!("verification time: {:?}", verification_time);
eprintln!("proof size: {:?}", proof_size);
verification_result
} }
fn generate_data(size: usize) -> Vec<u8> { fn generate_data(size: usize) -> Vec<u8> {

View File

@ -227,6 +227,7 @@ pub fn sha256_bench(size: usize) -> Result<()> {
let end = start.elapsed(); let end = start.elapsed();
(end, proof) (end, proof)
}; };
let proof_size = proof.to_bytes().len();
let (verification_time, res) = { let (verification_time, res) = {
let start = std::time::Instant::now(); let start = std::time::Instant::now();
@ -237,6 +238,7 @@ pub fn sha256_bench(size: usize) -> Result<()> {
eprintln!("Proof Generation Time: {:?}", proof_time); eprintln!("Proof Generation Time: {:?}", proof_time);
eprintln!("Verification Time: {:?}", verification_time); eprintln!("Verification Time: {:?}", verification_time);
eprintln!("Proof size: {:?}", proof_size);
res res