From 1edbf65010274acee38d445beba236e7293c66b4 Mon Sep 17 00:00:00 2001 From: Cyte Zhang Date: Tue, 26 Nov 2024 23:19:46 +0800 Subject: [PATCH] Refactor BaseFold hashing benchmark. (#556) Extract a small independent change from #294 Co-authored-by: Ming --- mpcs/benches/hashing.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/mpcs/benches/hashing.rs b/mpcs/benches/hashing.rs index 4dc107ed7..818cd7b6c 100644 --- a/mpcs/benches/hashing.rs +++ b/mpcs/benches/hashing.rs @@ -5,28 +5,19 @@ use goldilocks::Goldilocks; use mpcs::util::hash::{Digest, hash_two_digests}; use poseidon::poseidon_hash::PoseidonHash; +fn random_ceno_goldy() -> Goldilocks { + Goldilocks::random(&mut test_rng()) +} pub fn criterion_benchmark(c: &mut Criterion) { - let left = Digest( - vec![Goldilocks::random(&mut test_rng()); 4] - .try_into() - .unwrap(), - ); - let right = Digest( - vec![Goldilocks::random(&mut test_rng()); 4] - .try_into() - .unwrap(), - ); + let left = Digest(vec![random_ceno_goldy(); 4].try_into().unwrap()); + let right = Digest(vec![random_ceno_goldy(); 4].try_into().unwrap()); c.bench_function("ceno hash 2 to 1", |bencher| { bencher.iter(|| hash_two_digests(&left, &right)) }); - let values = (0..60) - .map(|_| Goldilocks::random(&mut test_rng())) - .collect::>(); + let values = (0..60).map(|_| random_ceno_goldy()).collect::>(); c.bench_function("ceno hash 60 to 1", |bencher| { - bencher.iter(|| { - PoseidonHash::hash_or_noop(&values); - }) + bencher.iter(|| PoseidonHash::hash_or_noop(&values)) }); }