Bit-order reversal benchmarks (#441)

This commit is contained in:
Jakub Nabaglo 2022-01-19 17:51:20 -08:00 committed by GitHub
parent dcf63f536e
commit f98a6adfbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -55,3 +55,7 @@ harness = false
[[bench]]
name = "transpose"
harness = false
[[bench]]
name = "reverse_index_bits"
harness = false

View File

@ -0,0 +1,30 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use plonky2::field::field_types::Field;
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2_util::{reverse_index_bits, reverse_index_bits_in_place};
type F = GoldilocksField;
fn benchmark_in_place(c: &mut Criterion) {
let mut group = c.benchmark_group("reverse-index-bits-in-place");
for width in [1 << 8, 1 << 16, 1 << 24] {
group.bench_with_input(BenchmarkId::from_parameter(width), &width, |b, _| {
let mut values = F::rand_vec(width);
b.iter(|| reverse_index_bits_in_place(&mut values));
});
}
}
fn benchmark_out_of_place(c: &mut Criterion) {
let mut group = c.benchmark_group("reverse-index-bits");
for width in [1 << 8, 1 << 16, 1 << 24] {
group.bench_with_input(BenchmarkId::from_parameter(width), &width, |b, _| {
let values = F::rand_vec(width);
b.iter(|| reverse_index_bits(&values));
});
}
}
criterion_group!(benches_in_place, benchmark_in_place);
criterion_group!(benches_out_of_place, benchmark_out_of_place);
criterion_main!(benches_in_place, benches_out_of_place);