Skip to content

Commit

Permalink
Sync upstream (#109)
Browse files Browse the repository at this point in the history
Co-authored-by: Linda Guiga <[email protected]>
Co-authored-by: Hamy Ratoanina <[email protected]>
Co-authored-by: Daniel-Aaron-Bloom <[email protected]>
Co-authored-by: nuno <[email protected]>
Co-authored-by: Matthias Görgens <[email protected]>
Co-authored-by: Robin Salen <[email protected]>
Co-authored-by: Gio <[email protected]>
Co-authored-by: Robin Salen <[email protected]>
  • Loading branch information
9 people committed Jul 18, 2024
1 parent 5387fbb commit 2b8432b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 2,005 deletions.
2 changes: 1 addition & 1 deletion plonky2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ name = "field_arithmetic"
harness = false

[[bench]]
name = "field_merkle_tree"
name = "batch_merkle_tree"
harness = false

[[bench]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod allocator;

use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::hash::field_merkle_tree::FieldMerkleTree;
use plonky2::hash::batch_merkle_tree::BatchMerkleTree;
use plonky2::hash::hash_types::RichField;
use plonky2::hash::keccak::KeccakHash;
use plonky2::hash::poseidon::PoseidonHash;
Expand All @@ -13,9 +13,9 @@ const ELEMS_PER_LEAF_1: usize = 70;
const ELEMS_PER_LEAF_2: usize = 5;
const ELEMS_PER_LEAF_3: usize = 100;

pub(crate) fn bench_field_merkle_tree<F: RichField, H: Hasher<F>>(c: &mut Criterion) {
let mut group = c.benchmark_group(&format!(
"field-merkle-tree<{}, {}>",
pub(crate) fn bench_batch_merkle_tree<F: RichField, H: Hasher<F>>(c: &mut Criterion) {
let mut group = c.benchmark_group(format!(
"batch-merkle-tree<{}, {}>",
type_name::<F>(),
type_name::<H>()
));
Expand All @@ -29,14 +29,14 @@ pub(crate) fn bench_field_merkle_tree<F: RichField, H: Hasher<F>>(c: &mut Criter
vec![F::rand_vec(ELEMS_PER_LEAF_2); size >> 1],
vec![F::rand_vec(ELEMS_PER_LEAF_3); size >> 2],
];
b.iter(|| FieldMerkleTree::<F, H>::new(black_box(leaves.clone()), black_box(5)));
b.iter(|| BatchMerkleTree::<F, H>::new(black_box(leaves.clone()), black_box(5)));
});
}
}

fn criterion_benchmark(c: &mut Criterion) {
bench_field_merkle_tree::<GoldilocksField, PoseidonHash>(c);
bench_field_merkle_tree::<GoldilocksField, KeccakHash<25>>(c);
bench_batch_merkle_tree::<GoldilocksField, PoseidonHash>(c);
bench_batch_merkle_tree::<GoldilocksField, KeccakHash<25>>(c);
}

criterion_group!(benches, criterion_benchmark);
Expand Down
Loading

0 comments on commit 2b8432b

Please sign in to comment.