2008-03-06 19:36:27 +08:00
|
|
|
// g++ -O3 -DNDEBUG -DMATSIZE=<x> benchmark.cpp -o benchmark && time ./benchmark
|
2007-12-29 00:20:00 +08:00
|
|
|
#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;
|
2007-12-24 19:14:25 +08:00
|
|
|
USING_PART_OF_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-04-11 22:28:42 +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-04-13 01:37:27 +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
|
|
|
}
|