dimforge / dimforge/nalgebra

2x speed difference vs hand-unrolled

Open
#135 8 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Hi,

Based on this blog post, I've decided to benchmark `nalgebra` and I've found it to be 2x slower. Any ideas why? I'm new to rust, so it's entirely possible I'm doing something wrong.

https://gist.github.com/yongqli/7ba8ef0e06fbfaebd98f takes `9.186 s` to run, so `9.18 ms` per 1 million iterations.

```
#[cfg(test)]
mod tests {
extern crate nalgebra;
extern crate test;

use super::*;
use nalgebra::*;

#[bench]
fn bench_4x4_mult(b: &mut test::Bencher) {
b.iter(|| {
let mut a = test::black_box(
Mat4::new(1., 1., 1., 1.,
1., 2., 1., 1.,
1., 1., 4., 1.,
1., 1., 1., 1.,)
);

let b = test::black_box(new_identity::>(4));

for _ in 0..1_000_000 {
// Mat4::inv_mut(&mut a);
a = a * b;
}
});
}
}
```

takes `22 ms` according to `cargo bench`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.