poly.rs 1003 B

123456789101112131415161718192021222324252627282930
  1. use criterion::{black_box, criterion_group, criterion_main, Criterion};
  2. use spiral_rs::poly::*;
  3. use spiral_rs::util::*;
  4. fn criterion_benchmark(c: &mut Criterion) {
  5. let params = get_test_params();
  6. let mut m1 = PolyMatrixRaw::random(&params, 10, 10);
  7. let mut m2 = PolyMatrixNTT::random(&params, 10, 10);
  8. let m3 = PolyMatrixNTT::random(&params, 10, 10);
  9. let mut m4 = PolyMatrixNTT::random(&params, 10, 10);
  10. // c.bench_function("nttf_noreduce 2048", |b| {
  11. // b.iter(|| to_ntt_no_reduce(black_box(&mut m2), black_box(&m1)))
  12. // });
  13. c.bench_function("multiply", |b| {
  14. b.iter(|| multiply(black_box(&mut m4), black_box(&m2), black_box(&m3)))
  15. });
  16. c.bench_function("nttf_full 2048", |b| {
  17. b.iter(|| to_ntt(black_box(&mut m2), black_box(&m1)))
  18. });
  19. c.bench_function("ntti_full 2048", |b| {
  20. b.iter(|| from_ntt(black_box(&mut m1), black_box(&m2)))
  21. });
  22. }
  23. criterion_group!(benches, criterion_benchmark);
  24. criterion_main!(benches);