I'm running some test in C++ to be sure that our program run in x86 and x64. I was really surprise to notice a speed improvement in x64. I'm running the test on a Win7 x64 machine. Is the x64 is faster because it is running on a 64 OS ? Or is it something in the code that is better in x64 ? I'm using VS 2008.
#include <iostream>
#include <ctime>
using namespace std;
#define ROWS 2000
#define COLS 2000
#define LOOP 100
int main()
{
float* m = new float[ROWS * COLS];
time_t begin, end;
time(&begin);
for (int n = 0; n < LOOP; ++n)
{
for (size_t row = 0; row < ROWS; ++row)
{
for (size_t col = 0; col < COLS; ++col)
{
m[row * COLS + col] = 1.0f * (rand() % 1000);
}
}
}
time(&end); double elapse = difftime(end, begin);
cout << "Done in " << elapse << " seconds" << endl;
delete[] m;
}
That simple test took 12 seconds in x86 and only 8 seconds in x64. Repro or explanation anyone ?
Thanks.