From d314b177005ededa89bba89ec6e15fa0a5dd1a23 Mon Sep 17 00:00:00 2001 From: Joey Beauvais-Feisthauer Date: Sat, 21 Dec 2024 03:35:07 -0500 Subject: [PATCH] Disable all benches for CI --- ext/crates/fp/Cargo.toml | 6 +- ext/crates/fp/benches/criterion.rs | 46 ------------ ext/crates/fp/benches/smallfq.rs | 113 ----------------------------- 3 files changed, 3 insertions(+), 162 deletions(-) delete mode 100644 ext/crates/fp/benches/criterion.rs delete mode 100644 ext/crates/fp/benches/smallfq.rs diff --git a/ext/crates/fp/Cargo.toml b/ext/crates/fp/Cargo.toml index b382d9b03..abff38abf 100644 --- a/ext/crates/fp/Cargo.toml +++ b/ext/crates/fp/Cargo.toml @@ -40,6 +40,6 @@ odd-primes = [] # name = "criterion" # harness = false -[[bench]] -name = "smallfq" -harness = false +# [[bench]] +# name = "smallfq" +# harness = false diff --git a/ext/crates/fp/benches/criterion.rs b/ext/crates/fp/benches/criterion.rs deleted file mode 100644 index bc3457629..000000000 --- a/ext/crates/fp/benches/criterion.rs +++ /dev/null @@ -1,46 +0,0 @@ -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; -use fp::{matrix::Matrix, prime::ValidPrime}; -use rand::Rng; - -fn random_matrix(p: ValidPrime, dimension: usize) -> Matrix { - Matrix::from_vec( - p, - &(0..dimension) - .map(|_| random_vector(p, dimension)) - .collect::>(), - ) -} - -fn row_reductions(c: &mut Criterion) { - for p in [2, 3, 5, 7].iter() { - let p = ValidPrime::new(*p); - let mut group = c.benchmark_group(format!("row_reduce_{p}")); - for dimension in [10, 20, 69, 100, 420, 1000] { - group.bench_function(format!("row_reduce_{p}_{dimension}"), move |b| { - b.iter_batched_ref( - || random_matrix(p, dimension), - |matrix| { - matrix.row_reduce(); - }, - BatchSize::SmallInput, - ) - }); - } - group.finish(); - } -} - -fn random_vector(p: ValidPrime, dimension: usize) -> Vec { - let mut result = Vec::with_capacity(dimension); - let mut rng = rand::thread_rng(); - result.resize_with(dimension, || rng.gen::() % p); - result -} - -criterion_group! { - name = row_reduction; - config = Criterion::default(); - targets = row_reductions -} - -criterion_main!(row_reduction); diff --git a/ext/crates/fp/benches/smallfq.rs b/ext/crates/fp/benches/smallfq.rs deleted file mode 100644 index 074728f1d..000000000 --- a/ext/crates/fp/benches/smallfq.rs +++ /dev/null @@ -1,113 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; -use fp::{ - field::{Field, SmallFq}, - prime::{Prime, ValidPrime, P2, P3, P5, P7}, - PRIMES, -}; -use pprof::criterion::{Output, PProfProfiler}; - -fn add_all_pairs(c: &mut Criterion, f_q: SmallFq

) { - let zero = f_q.zero(); - let one = f_q.one(); - let a = f_q.a(); - - let mut elements = vec![zero, one]; - for _ in 1..f_q.q() { - let prev = elements.last().unwrap(); - elements.push(*prev * a); - } - - c.bench_function(&format!("add_f_{}", f_q.q()), |b| { - b.iter(|| { - for &i in elements.iter() { - for &j in elements.iter() { - let _ = i + j; - } - } - }) - }); -} - -fn mul_all_pairs(c: &mut Criterion, f_q: SmallFq

) { - let zero = f_q.zero(); - let one = f_q.one(); - let a = f_q.a(); - - let mut elements = vec![zero, one]; - for _ in 1..f_q.q() { - let prev = elements.last().unwrap(); - elements.push(*prev * a); - } - - c.bench_function(&format!("mul_f_{}", f_q.q()), |b| { - b.iter(|| { - for &i in elements.iter() { - for &j in elements.iter() { - let _ = i * j; - } - } - }) - }); -} - -fn bench_add(c: &mut Criterion) { - const MAX_SIZE: u32 = 1000; - for d in 2.. { - if P2.pow(d) < MAX_SIZE { - add_all_pairs(c, SmallFq::new(P2, d)); - } else { - break; - } - if P3.pow(d) < MAX_SIZE { - add_all_pairs(c, SmallFq::new(P3, d)); - } - if P5.pow(d) < MAX_SIZE { - add_all_pairs(c, SmallFq::new(P5, d)); - } - if P7.pow(d) < MAX_SIZE { - add_all_pairs(c, SmallFq::new(P7, d)); - } - for p in PRIMES.iter().skip(4) { - if p.pow(d) < MAX_SIZE { - add_all_pairs(c, SmallFq::new(ValidPrime::new(*p), d)); - } else { - break; - } - } - } -} - -fn bench_mul(c: &mut Criterion) { - const MAX_SIZE: u32 = 1000; - for d in 2.. { - if P2.pow(d) < MAX_SIZE { - mul_all_pairs(c, SmallFq::new(P2, d)); - } else { - break; - } - if P3.pow(d) < MAX_SIZE { - mul_all_pairs(c, SmallFq::new(P3, d)); - } - if P5.pow(d) < MAX_SIZE { - mul_all_pairs(c, SmallFq::new(P5, d)); - } - if P7.pow(d) < MAX_SIZE { - mul_all_pairs(c, SmallFq::new(P7, d)); - } - for p in PRIMES.iter().skip(4) { - if p.pow(d) < MAX_SIZE { - mul_all_pairs(c, SmallFq::new(ValidPrime::new(*p), d)); - } else { - break; - } - } - } -} - -criterion_group! { - name = add; - config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); - targets = bench_add, bench_mul -} - -criterion_main!(add);