use criterion::{criterion_group, criterion_main, Criterion};
use ferrix::*;
fn dot_product_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("Dot Product");
group.bench_function("Vector.Vector", |b| {
b.iter_with_setup(
|| (Vector::<i32, 100>::random(), Vector::<i32, 100>::random()),
|(v1, v2)| v1.dot(v2),
);
});
group.bench_function("Vector.Matrix", |b| {
b.iter_with_setup(
|| {
(
Vector::<i32, 100>::random(),
Matrix::<i32, 100, 1>::random(),
)
},
|(v1, m1)| v1.dot(m1),
);
});
group.bench_function("RowVector.RowVector", |b| {
b.iter_with_setup(
|| {
(
RowVector::<i32, 100>::random(),
RowVector::<i32, 100>::random(),
)
},
|(v1, v2)| v1.dot(v2),
);
});
group.bench_function("RowVector.Matrix", |b| {
b.iter_with_setup(
|| {
(
RowVector::<i32, 100>::random(),
Matrix::<i32, 1, 100>::random(),
)
},
|(v1, m1)| v1.dot(m1),
);
});
}
criterion_group!(benches, dot_product_benchmark);
criterion_main!(benches);