source: pacpussensors/trunk/Vislab/lib3dv-1.2.0/lib3dv/eigen/bench/quatmul.cpp@ 139

Last change on this file since 139 was 136, checked in by ldecherf, 8 years ago

Doc

File size: 1.1 KB
Line 
1#include <iostream>
2#include <Eigen/Core>
3#include <Eigen/Geometry>
4#include <bench/BenchTimer.h>
5
6using namespace Eigen;
7
8template<typename Quat>
9EIGEN_DONT_INLINE void quatmul_default(const Quat& a, const Quat& b, Quat& c)
10{
11 c = a * b;
12}
13
14template<typename Quat>
15EIGEN_DONT_INLINE void quatmul_novec(const Quat& a, const Quat& b, Quat& c)
16{
17 c = internal::quat_product<0, Quat, Quat, typename Quat::Scalar, Aligned>::run(a,b);
18}
19
20template<typename Quat> void bench(const std::string& label)
21{
22 int tries = 10;
23 int rep = 1000000;
24 BenchTimer t;
25
26 Quat a(4, 1, 2, 3);
27 Quat b(2, 3, 4, 5);
28 Quat c;
29
30 std::cout.precision(3);
31
32 BENCH(t, tries, rep, quatmul_default(a,b,c));
33 std::cout << label << " default " << 1e3*t.best(CPU_TIMER) << "ms \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
34
35 BENCH(t, tries, rep, quatmul_novec(a,b,c));
36 std::cout << label << " novec " << 1e3*t.best(CPU_TIMER) << "ms \t" << 1e-6*double(rep)/(t.best(CPU_TIMER)) << " M mul/s\n";
37}
38
39int main()
40{
41 bench<Quaternionf>("float ");
42 bench<Quaterniond>("double");
43
44 return 0;
45
46}
47
Note: See TracBrowser for help on using the repository browser.