Home | History | Annotate | Download | only in bench
      1 #include <iostream>
      2 #include <Eigen/Core>
      3 #include <Eigen/Geometry>
      4 #include <bench/BenchTimer.h>
      5 
      6 using namespace Eigen;
      7 
      8 template<typename Quat>
      9 EIGEN_DONT_INLINE void quatmul_default(const Quat& a, const Quat& b, Quat& c)
     10 {
     11   c = a * b;
     12 }
     13 
     14 template<typename Quat>
     15 EIGEN_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 
     20 template<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 
     39 int main()
     40 {
     41   bench<Quaternionf>("float ");
     42   bench<Quaterniond>("double");
     43 
     44   return 0;
     45 
     46 }
     47 
     48