Skip to content

Commit cd0608d

Browse files
committed
Add benchmark for vcos
1 parent 628e156 commit cd0608d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

intel-mkl-sys/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ edition = "2018"
66

77
[dependencies.intel-mkl-src]
88
path = "../intel-mkl-src"
9+
10+
[dev-dependencies]
11+
criterion = "*"
12+
13+
[[bench]]
14+
name = "cos"
15+
harness = false

intel-mkl-sys/benches/cos.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[macro_use]
2+
extern crate criterion;
3+
4+
use criterion::Criterion;
5+
6+
fn criterion_benchmark(c: &mut Criterion) {
7+
for &n in &[100, 1000, 10000] {
8+
c.bench_function(&format!("cos{}", n), |b| {
9+
let in_ = vec![0.0_f64; n];
10+
let mut out = vec![0.0_f64; n];
11+
b.iter(|| {
12+
for i in 0..n {
13+
out[i] = in_[i].cos();
14+
}
15+
})
16+
});
17+
18+
c.bench_function(&format!("vcos{}", n), |b| {
19+
let in_ = vec![0.0_f64; n];
20+
let mut out = vec![0.0_f64; n];
21+
b.iter(|| unsafe {
22+
intel_mkl_sys::vdCos(n as i32, in_.as_ptr(), out.as_mut_ptr());
23+
})
24+
});
25+
}
26+
}
27+
28+
criterion_group!(benches, criterion_benchmark);
29+
criterion_main!(benches);

0 commit comments

Comments
 (0)