The simple use of the resize method shows differences in perfs between versions of eigen.
# include <Eigen/Dense>
# include <iostream>
# include <sys/time.h>
typedef Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrixN;
typedef Eigen::Matrix< double, 3, 3 > matrix3d;
int main()
{
int N=1e8;
long TICKS_PER_SECOND = 1e6;
struct timeval tv_start, tv_stop;
matrixN m1 = matrixN::Random(3,3);
matrix3d m2 = matrix3d::Random();
std::cout << "Resize dynamic size matrix\n ";
long time_usec = 0;
::gettimeofday(&tv_start, NULL);
for(int i=0; i<N; i++)
m1.resize(4,4);
::gettimeofday(&tv_stop, NULL);
time_usec = ( tv_stop.tv_sec - tv_start.tv_sec ) * TICKS_PER_SECOND
+ ( tv_stop.tv_usec - tv_start.tv_usec );
std::cout
<< "average execution time = " << (double)time_usec/(double)N << "µs"
<< std::endl;
std::cout << "Resize fixed size matrix (sic)\n ";
time_usec = 0;
::gettimeofday(&tv_start, NULL);
for(int i=0; i<N; i++)
m2.resize(4,4); // Should send me to prison
::gettimeofday(&tv_stop, NULL);
time_usec = ( tv_stop.tv_sec - tv_start.tv_sec ) * TICKS_PER_SECOND
+ ( tv_stop.tv_usec - tv_start.tv_usec );
std::cout
<< "average execution time = " << (double)time_usec/(double)N << "µs"
<< std::endl;
}
I built it with either eigen 3.0.3, eigen 3.1 or with the mercurial head. All tests were made and the same machine, with the same load, and were ran on turn several times, and the results were consistant. Here are the average execution times:
Hope this helps.
P.S.: Not sure if useful, but my proc is an Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz, I'm running on Ubuntu 12.04, and compiling with gcc 4.6.3