From 15e13a552e57501cf398f0bc1dac7a657900f16c Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Thu, 23 Nov 2023 11:04:44 -0700 Subject: [PATCH] Fix benchmark build (#302) Benchmarks weren't building without the `alloc` feature. Also adds CI that ensures the benchmarks build with no features. --- .github/workflows/crypto-bigint.yml | 1 + benches/bench.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/crypto-bigint.yml b/.github/workflows/crypto-bigint.yml index ce28d0e5..1b9a3257 100644 --- a/.github/workflows/crypto-bigint.yml +++ b/.github/workflows/crypto-bigint.yml @@ -136,6 +136,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: 1.70.0 + - run: cargo build --benches - run: cargo build --all-features --benches doc: diff --git a/benches/bench.rs b/benches/bench.rs index d39cf70d..acbd8b20 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -3,10 +3,13 @@ use criterion::{ }; use crypto_bigint::{ modular::{DynResidue, DynResidueParams}, - Limb, MultiExponentiate, NonZero, Random, Reciprocal, U128, U2048, U256, + Limb, NonZero, Random, Reciprocal, U128, U2048, U256, }; use rand_core::OsRng; +#[cfg(feature = "alloc")] +use crypto_bigint::MultiExponentiate; + fn bench_division(group: &mut BenchmarkGroup<'_, M>) { group.bench_function("div/rem, U256/U128, full size", |b| { b.iter_batched( @@ -102,6 +105,7 @@ fn bench_montgomery_ops(group: &mut BenchmarkGroup<'_, M>) { ) }); + #[cfg(feature = "alloc")] for i in [1, 2, 3, 4, 10, 100] { group.bench_function( format!("multi_exponentiate for {i} bases, U256^U256"),