permutation.rs 713 B

1234567891011121314151617181920
  1. use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
  2. use utils::permutation::{FisherYatesPermutation, Permutation};
  3. const LOG_DOMAIN_SIZES: [u32; 4] = [8, 12, 16, 20];
  4. pub fn bench_permutation(c: &mut Criterion) {
  5. for log_domain_size in LOG_DOMAIN_SIZES {
  6. c.bench_with_input(
  7. BenchmarkId::new("FisherYates", log_domain_size),
  8. &log_domain_size,
  9. |b, &log_domain_size| {
  10. let key = FisherYatesPermutation::sample(1 << log_domain_size);
  11. b.iter(|| black_box(FisherYatesPermutation::from_key(key)))
  12. },
  13. );
  14. }
  15. }
  16. criterion_group!(benches, bench_permutation);
  17. criterion_main!(benches);