Skip to content

Commit 899c81c

Browse files
committed
Add benchmarks for Boxed prime number generation
cargo fmt
1 parent 64965d0 commit 899c81c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

benches/bench.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::num::NonZeroU32;
22

33
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
4-
use crypto_bigint::{nlimbs, Integer, Odd, RandomBits, Uint, U1024, U128, U256};
4+
use crypto_bigint::{nlimbs, BoxedUint, Integer, Odd, RandomBits, Uint, U1024, U128, U256};
55
use rand_chacha::ChaCha8Rng;
66
use rand_core::{CryptoRngCore, OsRng, SeedableRng};
77

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

241+
let mut rng = make_rng();
242+
group.bench_function("(Boxed128) Random safe prime", |b| {
243+
b.iter(|| generate_safe_prime_with_rng::<BoxedUint>(&mut rng, 128, 128))
244+
});
245+
246+
group.sample_size(20);
247+
let mut rng = make_rng();
248+
group.bench_function("(Boxed1024) Random safe prime", |b| {
249+
b.iter(|| generate_safe_prime_with_rng::<BoxedUint>(&mut rng, 1024, 1024))
250+
});
251+
241252
group.finish();
242253

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

0 commit comments

Comments
 (0)