2008-04-11 16:18:47 +08:00
|
|
|
// g++ -O3 -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX
|
|
|
|
|
|
|
|
#include <Eigen/Core>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
|
|
|
|
2008-04-18 15:57:46 +08:00
|
|
|
#ifndef VECTYPE
|
|
|
|
#define VECTYPE VectorXLd
|
2008-04-11 16:18:47 +08:00
|
|
|
#endif
|
|
|
|
|
2008-04-18 15:57:46 +08:00
|
|
|
#ifndef VECSIZE
|
|
|
|
#define VECSIZE 1000000
|
2008-04-11 16:18:47 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef REPEAT
|
2008-04-13 01:37:27 +08:00
|
|
|
#define REPEAT 1000
|
2008-04-11 16:18:47 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2008-07-27 19:39:47 +08:00
|
|
|
VECTYPE I = VECTYPE::Ones(VECSIZE);
|
2008-04-18 15:57:46 +08:00
|
|
|
VECTYPE m(VECSIZE,1);
|
|
|
|
for(int i = 0; i < VECSIZE; i++)
|
2008-04-11 16:18:47 +08:00
|
|
|
{
|
2008-04-18 15:57:46 +08:00
|
|
|
m[i] = 0.1 * i/VECSIZE;
|
2008-04-11 16:18:47 +08:00
|
|
|
}
|
|
|
|
for(int a = 0; a < REPEAT; a++)
|
|
|
|
{
|
2008-07-27 19:39:47 +08:00
|
|
|
m = VECTYPE::Ones(VECSIZE) + 0.00005 * (m.cwise().square() + m/4);
|
2008-04-11 16:18:47 +08:00
|
|
|
}
|
2008-04-18 15:57:46 +08:00
|
|
|
cout << m[0] << endl;
|
2008-04-11 16:18:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|