From 25046d6c56bbf9ddcc1bb400d6617cc79985a43f Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Tue, 14 Feb 2017 19:07:02 +0100 Subject: [PATCH] Add benchmarks for Cholesky::solve --- benches/lib.rs | 1 + benches/linalg/cholesky.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/benches/lib.rs b/benches/lib.rs index 95cdd4b..57a27ca 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -1,5 +1,6 @@ #![feature(test)] +#[macro_use] extern crate rulinalg; extern crate num as libnum; extern crate test; diff --git a/benches/linalg/cholesky.rs b/benches/linalg/cholesky.rs index 4ece138..f7b6797 100644 --- a/benches/linalg/cholesky.rs +++ b/benches/linalg/cholesky.rs @@ -47,3 +47,23 @@ fn cholesky_500x500(b: &mut Bencher) { x.cholesky().expect("Matrix is invertible") }) } + +#[bench] +fn cholesky_solve_1000x1000(b: &mut Bencher) { + let n = 1000; + let x = Matrix::identity(n); + let cholesky = Cholesky::decompose(x).unwrap(); + b.iter(|| { + cholesky.solve(vector![0.0; n]) + }); +} + +#[bench] +fn cholesky_solve_100x100(b: &mut Bencher) { + let n = 100; + let x = Matrix::identity(n); + let cholesky = Cholesky::decompose(x).unwrap(); + b.iter(|| { + cholesky.solve(vector![0.0; n]) + }); +}