2008-03-06 19:36:27 +08:00
|
|
|
// g++ -O3 -DNDEBUG -DMATSIZE=<x> benchmark.cpp -o benchmark && time ./benchmark
|
2010-07-09 09:59:36 +08:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <Eigen/Core>
|
2007-12-21 05:11:05 +08:00
|
|
|
|
2008-03-06 19:36:27 +08:00
|
|
|
#ifndef MATSIZE
|
|
|
|
#define MATSIZE 3
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace std;
|
2010-04-23 06:27:13 +08:00
|
|
|
using namespace Eigen;
|
2007-12-21 05:11:05 +08:00
|
|
|
|
2008-04-07 02:01:03 +08:00
|
|
|
#ifndef REPEAT
|
|
|
|
#define REPEAT 40000000
|
|
|
|
#endif
|
|
|
|
|
2008-04-10 17:01:28 +08:00
|
|
|
#ifndef SCALAR
|
|
|
|
#define SCALAR double
|
|
|
|
#endif
|
|
|
|
|
2007-12-21 05:11:05 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2008-07-27 19:39:47 +08:00
|
|
|
Matrix<SCALAR,MATSIZE,MATSIZE> I = Matrix<SCALAR,MATSIZE,MATSIZE>::Ones();
|
2008-04-10 17:01:28 +08:00
|
|
|
Matrix<SCALAR,MATSIZE,MATSIZE> m;
|
2008-03-06 19:36:27 +08:00
|
|
|
for(int i = 0; i < MATSIZE; i++)
|
|
|
|
for(int j = 0; j < MATSIZE; j++)
|
|
|
|
{
|
|
|
|
m(i,j) = (i+MATSIZE*j);
|
|
|
|
}
|
|
|
|
asm("#begin");
|
2008-04-07 02:01:03 +08:00
|
|
|
for(int a = 0; a < REPEAT; a++)
|
2008-03-06 19:36:27 +08:00
|
|
|
{
|
2008-07-27 19:39:47 +08:00
|
|
|
m = Matrix<SCALAR,MATSIZE,MATSIZE>::Ones() + 0.00005 * (m + (m*m));
|
2008-03-06 19:36:27 +08:00
|
|
|
}
|
|
|
|
asm("#end");
|
|
|
|
cout << m << endl;
|
|
|
|
return 0;
|
2007-12-21 05:11:05 +08:00
|
|
|
}
|