aboutsummaryrefslogtreecommitdiff
path: root/bench/quatmul.cpp
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2012-11-02 10:59:05 +0000
committerXiaotao Duan <xiaotao@google.com>2012-11-07 14:17:48 -0800
commitc981c48f5bc9aefeffc0bcb0cc3934c2fae179dd (patch)
tree54d1c7d66098154c1d7c5bd414394ef4cf255810 /bench/quatmul.cpp
parent63f67d748682b46d58be31235a0a2d64d81b998c (diff)
downloadeigen-jb-mr1.1-release.tar.gz
Added a README.android and a MODULE_LICENSE_MPL2 file. Added empty Android.mk and CleanSpec.mk to optimize Android build. Non MPL2 license code is disabled in ./Eigen/src/Core/util/NonMPL2.h. Trying to include such files will lead to an error. Change-Id: I0e148b7c3e83999bcc4dfaa5809d33bfac2aac32
Diffstat (limited to 'bench/quatmul.cpp')
-rw-r--r--bench/quatmul.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/bench/quatmul.cpp b/bench/quatmul.cpp
new file mode 100644
index 000000000..8d9d7922c
--- /dev/null
+++ b/bench/quatmul.cpp
@@ -0,0 +1,47 @@
+#include <iostream>
+#include <Eigen/Core>
+#include <Eigen/Geometry>
+#include <bench/BenchTimer.h>
+
+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, Aligned>::run(a,b);
+}
+
+template<typename Quat> void bench(const std::string& label)
+{
+ int tries = 10;
+ int rep = 1000000;
+ BenchTimer t;
+
+ Quat a(4, 1, 2, 3);
+ Quat b(2, 3, 4, 5);
+ Quat c;
+
+ std::cout.precision(3);
+
+ BENCH(t, tries, rep, quatmul_default(a,b,c));
+ std::cout << label << " default " << 1e3*t.best(CPU_TIMER) << "ms \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
+
+ BENCH(t, tries, rep, quatmul_novec(a,b,c));
+ std::cout << label << " novec " << 1e3*t.best(CPU_TIMER) << "ms \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
+}
+
+int main()
+{
+ bench<Quaternionf>("float ");
+ bench<Quaterniond>("double");
+
+ return 0;
+
+}
+