From 899c81cc4828e39c63f482464593e95269bba5fa Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Thu, 28 Dec 2023 16:06:23 -0800 Subject: [PATCH] Add benchmarks for Boxed prime number generation cargo fmt --- benches/bench.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/benches/bench.rs b/benches/bench.rs index fcec0e2..d4f22ed 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -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}; @@ -238,6 +238,17 @@ fn bench_presets(c: &mut Criterion) { b.iter(|| generate_safe_prime_with_rng::(&mut rng, 1024, 1024)) }); + let mut rng = make_rng(); + group.bench_function("(Boxed128) Random safe prime", |b| { + b.iter(|| generate_safe_prime_with_rng::(&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::(&mut rng, 1024, 1024)) + }); + group.finish(); // A separate group for bounded tests, to make it easier to run them separately.