The same source code is compiled with g++ (linux) and with visual c++. I found that the program runs much slower on the second one (0.03 seconds vs 0.359 seconds).
The program uses <vector> and does a convolution:
void DSP_fir_gen1
(
vector < double > *x,
double *h,
vector < double > *r,
int nh,
int nr
)
{
int i, j;
double sum;
(*r).clear();
for (j = 0; j < nr; j++)
{
sum = 0;
for (i = 0; i < nh; i++)
{
sum += (*x)[i + j] * h[i];
}
(*r).push_back(sum);
}
}
The aprox. "x" width is about 36656 doubles and "h" is between 2 and 25. I don't understand why the program compiled in visual c++ 6 is so painfully slow.
When I compile in linux I use the options:
-O0 -g3 -Wall -c -fmessage-length=0
And in visual c++ 6.0:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/QRSdetectMain.pdb" /debug /machine:I386 /out:"Debug/QRSdetectMain.exe" /pdbtype:sept
My PC is a Pentium 4 intel 3.2 Ghz 3.2 Ghz 512 Mb RAM.