Skip to content

Commit

Permalink
iter_batched in benches
Browse files Browse the repository at this point in the history
  • Loading branch information
ivolkg committed Dec 2, 2024
1 parent 0435121 commit db01c36
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
24 changes: 14 additions & 10 deletions latticefold/benches/decomposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,20 @@ fn verifier_decomposition_benchmark<
),
&(lcccs, decomposition_proof, ccs),
|b, (lcccs, proof, ccs)| {
b.iter(|| {
let mut bench_verifier_transcript = verifier_transcript.clone();
let _ = LFDecompositionVerifier::<_, PoseidonTranscript<R, CS>>::verify::<C, P>(
lcccs,
proof,
&mut bench_verifier_transcript,
ccs,
)
.expect("Failed to verify decomposition proof");
})
b.iter_batched(
|| verifier_transcript.clone(),
|mut bench_verifier_transcript| {
let _ =
LFDecompositionVerifier::<_, PoseidonTranscript<R, CS>>::verify::<C, P>(
lcccs,
proof,
&mut bench_verifier_transcript,
ccs,
)
.expect("Failed to verify decomposition proof");
},
criterion::BatchSize::SmallInput,
);
},
);
}
Expand Down
27 changes: 17 additions & 10 deletions latticefold/benches/folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ fn verifier_folding_benchmark<
)
.expect("Failed to generate folding proof");

println!(
"Size of verifier transcript: {}",
std::mem::size_of_val(&verifier_transcript)
);
c.bench_with_input(
BenchmarkId::new(
"Folding Verifier",
Expand All @@ -205,16 +209,19 @@ fn verifier_folding_benchmark<
),
&(lcccs, folding_proof, ccs),
|b, (lcccs_vec, proof, ccs)| {
b.iter(|| {
let mut bench_verifier_transcript = verifier_transcript.clone();
let _ = LFFoldingVerifier::<_, PoseidonTranscript<R, CS>>::verify::<C, P>(
lcccs_vec,
proof,
&mut bench_verifier_transcript,
ccs,
)
.expect("Failed to verify folding proof");
})
b.iter_batched(
|| verifier_transcript.clone(),
|mut bench_verifier_transcript| {
let _ = LFFoldingVerifier::<_, PoseidonTranscript<R, CS>>::verify::<C, P>(
lcccs_vec,
proof,
&mut bench_verifier_transcript,
ccs,
)
.expect("Failed to verify folding proof");
},
criterion::BatchSize::SmallInput,
);
},
);
}
Expand Down
28 changes: 16 additions & 12 deletions latticefold/benches/linearization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn prover_linearization_benchmark<
const W: usize,
P: DecompositionParams,
R: SuitableRing,
CS: LatticefoldChallengeSet<R>,
CS: LatticefoldChallengeSet<R> + Clone,
>(
c: &mut criterion::BenchmarkGroup<criterion::measurement::WallTime>,
cm_i: &CCCS<C, R>,
Expand Down Expand Up @@ -58,15 +58,19 @@ fn prover_linearization_benchmark<
),
&(cm_i, wit, ccs),
|b, (cm_i, wit, ccs)| {
b.iter(|| {
let _ = LFLinearizationProver::<_, PoseidonTranscript<R, CS>>::prove(
cm_i,
wit,
&mut transcript,
ccs,
)
.expect("Failed to generate linearization proof");
})
b.iter_batched(
|| transcript.clone(),
|mut bench_transcript| {
let _ = LFLinearizationProver::<_, PoseidonTranscript<R, CS>>::prove(
cm_i,
wit,
&mut bench_transcript,
ccs,
)
.expect("Failed to generate linearization proof");
},
criterion::BatchSize::SmallInput,
);
},
);
res
Expand All @@ -77,7 +81,7 @@ fn verifier_linearization_benchmark<
const W: usize,
P: DecompositionParams,
R: SuitableRing,
CS: LatticefoldChallengeSet<R>,
CS: LatticefoldChallengeSet<R> + Clone,
>(
c: &mut criterion::BenchmarkGroup<criterion::measurement::WallTime>,
cm_i: &CCCS<C, R>,
Expand Down Expand Up @@ -118,7 +122,7 @@ fn linearization_benchmarks<
const C: usize,
const WIT_LEN: usize,
const W: usize,
CS: LatticefoldChallengeSet<R>,
CS: LatticefoldChallengeSet<R> + Clone,
R: SuitableRing,
P: DecompositionParams,
>(
Expand Down

0 comments on commit db01c36

Please sign in to comment.