mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 17:23:08 +00:00
* Fix egregious magic number. * Remove generic consts from core permutations. * Remove redundant `where` clauses. * Remove HashConfig and friends. * Refactor Permutation code. * Remove redundant `where` clauses and `use`s. * Introduce AlgebraicPermutation to wrap `[Target; WIDTH]`s. * Remove `generic_const_expr` feature from plonky2! * Remove `generic_const_expr` feature from plonky2! * Compile time fixed! Start removing `generic_const_expr` from evm. * Remove redundant `where` clauses from Starky. * Remove `generic_const_expr`s from benchmarks. * Remove redundant HASH_SIZE `where` clause. * Clippy. * Fix unrelated OsRng issue in `bench_recursion`. * Fix function doc.
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
mod allocator;
|
|
|
|
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
|
use plonky2::field::goldilocks_field::GoldilocksField;
|
|
use plonky2::field::types::Sample;
|
|
use plonky2::hash::hash_types::{BytesHash, RichField};
|
|
use plonky2::hash::keccak::KeccakHash;
|
|
use plonky2::hash::poseidon::{Poseidon, SPONGE_WIDTH};
|
|
use plonky2::plonk::config::Hasher;
|
|
use tynm::type_name;
|
|
|
|
pub(crate) fn bench_keccak<F: RichField>(c: &mut Criterion) {
|
|
c.bench_function("keccak256", |b| {
|
|
b.iter_batched(
|
|
|| (BytesHash::<32>::rand(), BytesHash::<32>::rand()),
|
|
|(left, right)| <KeccakHash<32> as Hasher<F>>::two_to_one(left, right),
|
|
BatchSize::SmallInput,
|
|
)
|
|
});
|
|
}
|
|
|
|
pub(crate) fn bench_poseidon<F: Poseidon>(c: &mut Criterion) {
|
|
c.bench_function(
|
|
&format!("poseidon<{}, {SPONGE_WIDTH}>", type_name::<F>()),
|
|
|b| {
|
|
b.iter_batched(
|
|
|| F::rand_array::<SPONGE_WIDTH>(),
|
|
|state| F::poseidon(state),
|
|
BatchSize::SmallInput,
|
|
)
|
|
},
|
|
);
|
|
}
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
|
bench_poseidon::<GoldilocksField>(c);
|
|
bench_keccak::<GoldilocksField>(c);
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|