2019-12-19 22:11:11 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
2019-08-15 16:39:55 +00:00
|
|
|
use pairing::bls12_381::Bls12;
|
2019-09-28 07:48:43 +00:00
|
|
|
use rand_core::{OsRng, RngCore};
|
2019-08-06 09:46:40 +00:00
|
|
|
use zcash_primitives::jubjub::JubjubBls12;
|
|
|
|
use zcash_primitives::pedersen_hash::{pedersen_hash, Personalization};
|
2018-07-25 20:46:00 +00:00
|
|
|
|
2019-12-19 22:11:11 +00:00
|
|
|
fn bench_pedersen_hash(c: &mut Criterion) {
|
2018-07-25 20:46:00 +00:00
|
|
|
let params = JubjubBls12::new();
|
2019-08-06 09:46:40 +00:00
|
|
|
let rng = &mut OsRng;
|
2019-08-15 16:39:55 +00:00
|
|
|
let bits = (0..510)
|
|
|
|
.map(|_| (rng.next_u32() % 2) != 0)
|
|
|
|
.collect::<Vec<_>>();
|
2018-07-25 20:46:00 +00:00
|
|
|
let personalization = Personalization::MerkleTree(31);
|
|
|
|
|
2019-12-19 22:11:11 +00:00
|
|
|
c.bench_function("Pedersen hash", |b| {
|
|
|
|
b.iter(|| pedersen_hash::<Bls12, _>(personalization, bits.clone(), ¶ms))
|
|
|
|
});
|
2018-07-25 20:46:00 +00:00
|
|
|
}
|
2019-12-19 22:11:11 +00:00
|
|
|
|
|
|
|
criterion_group!(benches, bench_pedersen_hash);
|
|
|
|
criterion_main!(benches);
|