This commit is contained in:
Jean-Philippe Bossuat
2024-12-20 17:09:47 +01:00
parent 45aebc3976
commit 7344d78173
8 changed files with 261 additions and 6 deletions

40
benches/operations.rs Normal file
View File

@@ -0,0 +1,40 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use math::ring::Ring;
use math::modulus::Operations;
fn add_vec_unary(c: &mut Criterion) {
fn runner(r: Ring<u64>) -> Box<dyn FnMut()> {
let mut p0: math::poly::Poly<u64> = r.new_poly();
let mut p1: math::poly::Poly<u64> = r.new_poly();
for i in 0..p0.n(){
p0.0[i] = i as u64;
p1.0[i] = i as u64;
}
println!("{}", r.n());
Box::new(move || {
r.modulus.add_vec_unary_assign::<8>(&p0.0, &mut p1.0);
})
}
let mut b: criterion::BenchmarkGroup<'_, criterion::measurement::WallTime> = c.benchmark_group("add_vec_unary");
for log_n in 11..17 {
let n: usize = 1<<log_n as usize;
let q_base: u64 = 0x1fffffffffe00001u64;
let q_power: usize = 1usize;
let r: Ring<u64> = Ring::<u64>::new(n, q_base, q_power);
let runners = [
("prime", {
runner(r)
}),
];
for (name, mut runner) in runners {
let id = BenchmarkId::new(name, n);
b.bench_with_input(id, &(), |b, _| b.iter(&mut runner));
}
}
}
criterion_group!(benches, add_vec_unary);
criterion_main!(benches);