mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Migrate Eigen benchmarks to the Google benchmark framework
libeigen/eigen!2132 Closes #3025 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
38
benchmarks/quatmul.cpp
Normal file
38
benchmarks/quatmul.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
template <typename Quat>
|
||||
EIGEN_DONT_INLINE void quatmul_default(const Quat& a, const Quat& b, Quat& c) {
|
||||
c = a * b;
|
||||
}
|
||||
|
||||
template <typename Quat>
|
||||
EIGEN_DONT_INLINE void quatmul_novec(const Quat& a, const Quat& b, Quat& c) {
|
||||
c = internal::quat_product<0, Quat, Quat, typename Quat::Scalar>::run(a, b);
|
||||
}
|
||||
|
||||
template <typename Quat>
|
||||
static void BM_QuatMul_Default(benchmark::State& state) {
|
||||
Quat a(4, 1, 2, 3), b(2, 3, 4, 5), c;
|
||||
for (auto _ : state) {
|
||||
quatmul_default(a, b, c);
|
||||
benchmark::DoNotOptimize(c.coeffs().data());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Quat>
|
||||
static void BM_QuatMul_NoVec(benchmark::State& state) {
|
||||
Quat a(4, 1, 2, 3), b(2, 3, 4, 5), c;
|
||||
for (auto _ : state) {
|
||||
quatmul_novec(a, b, c);
|
||||
benchmark::DoNotOptimize(c.coeffs().data());
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(BM_QuatMul_Default<Quaternionf>);
|
||||
BENCHMARK(BM_QuatMul_NoVec<Quaternionf>);
|
||||
BENCHMARK(BM_QuatMul_Default<Quaterniond>);
|
||||
BENCHMARK(BM_QuatMul_NoVec<Quaterniond>);
|
||||
Reference in New Issue
Block a user