You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
795 B

  1. // g++ -O3 -DNDEBUG -DMATSIZE=<x> benchmark.cpp -o benchmark && time ./benchmark
  2. #include <iostream>
  3. #include <Eigen/Core>
  4. #ifndef MATSIZE
  5. #define MATSIZE 3
  6. #endif
  7. using namespace std;
  8. using namespace StormEigen;
  9. #ifndef REPEAT
  10. #define REPEAT 40000000
  11. #endif
  12. #ifndef SCALAR
  13. #define SCALAR double
  14. #endif
  15. int main(int argc, char *argv[])
  16. {
  17. Matrix<SCALAR,MATSIZE,MATSIZE> I = Matrix<SCALAR,MATSIZE,MATSIZE>::Ones();
  18. Matrix<SCALAR,MATSIZE,MATSIZE> m;
  19. for(int i = 0; i < MATSIZE; i++)
  20. for(int j = 0; j < MATSIZE; j++)
  21. {
  22. m(i,j) = (i+MATSIZE*j);
  23. }
  24. asm("#begin");
  25. for(int a = 0; a < REPEAT; a++)
  26. {
  27. m = Matrix<SCALAR,MATSIZE,MATSIZE>::Ones() + 0.00005 * (m + (m*m));
  28. }
  29. asm("#end");
  30. cout << m << endl;
  31. return 0;
  32. }