Skip to content

Commit

Permalink
Fix benchmark build (#302)
Browse files Browse the repository at this point in the history
Benchmarks weren't building without the `alloc` feature.

Also adds CI that ensures the benchmarks build with no features.
  • Loading branch information
tarcieri authored Nov 23, 2023
1 parent bfb0ac1 commit 15e13a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/crypto-bigint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
group.bench_function("div/rem, U256/U128, full size", |b| {
b.iter_batched(
Expand Down Expand Up @@ -102,6 +105,7 @@ fn bench_montgomery_ops<M: Measurement>(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"),
Expand Down

0 comments on commit 15e13a5

Please sign in to comment.