Skip to content

Commit

Permalink
Refactor BaseFold hashing benchmark. (#556)
Browse files Browse the repository at this point in the history
Extract a small independent change from #294

Co-authored-by: Ming <[email protected]>
  • Loading branch information
yczhangsjtu and hero78119 authored Nov 26, 2024
1 parent 0ea9248 commit 1edbf65
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions mpcs/benches/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();
let values = (0..60).map(|_| random_ceno_goldy()).collect::<Vec<_>>();
c.bench_function("ceno hash 60 to 1", |bencher| {
bencher.iter(|| {
PoseidonHash::hash_or_noop(&values);
})
bencher.iter(|| PoseidonHash::hash_or_noop(&values))
});
}

Expand Down

0 comments on commit 1edbf65

Please sign in to comment.