Skip to content

Commit

Permalink
Add benchmarks for Boxed prime number generation
Browse files Browse the repository at this point in the history
cargo fmt
  • Loading branch information
fjarri committed Dec 29, 2023
1 parent 64965d0 commit 899c81c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::num::NonZeroU32;

use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use crypto_bigint::{nlimbs, Integer, Odd, RandomBits, Uint, U1024, U128, U256};
use crypto_bigint::{nlimbs, BoxedUint, Integer, Odd, RandomBits, Uint, U1024, U128, U256};
use rand_chacha::ChaCha8Rng;
use rand_core::{CryptoRngCore, OsRng, SeedableRng};

Expand Down Expand Up @@ -238,6 +238,17 @@ fn bench_presets(c: &mut Criterion) {
b.iter(|| generate_safe_prime_with_rng::<U1024>(&mut rng, 1024, 1024))
});

let mut rng = make_rng();
group.bench_function("(Boxed128) Random safe prime", |b| {
b.iter(|| generate_safe_prime_with_rng::<BoxedUint>(&mut rng, 128, 128))
});

group.sample_size(20);
let mut rng = make_rng();
group.bench_function("(Boxed1024) Random safe prime", |b| {
b.iter(|| generate_safe_prime_with_rng::<BoxedUint>(&mut rng, 1024, 1024))
});

group.finish();

// A separate group for bounded tests, to make it easier to run them separately.
Expand Down

0 comments on commit 899c81c

Please sign in to comment.