Re: how could "atof" be so slow in vc2005?
"Leo Jay" <Python.LeoJay@gmail.com> wrote in message
news:1188889204.274768.8590@57g2000hsv.googlegroups.com...
i'm using visual studio 2005, and compile the code in release mode
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <math.h>
using namespace std;
int main()
{
int i = 0;
double sum = 0.0;
clock_t start = clock();
for (i=0; i<10000000; i++)
{
sum += atof("1.123400e01");
}
cout << "time: " << double(clock() - start) / CLOCKS_PER_SEC <<
"\tresult: " << sum << endl;
return 0;
}
the code runs more than 7.0 seconds on my Intel Xeon 3.0 box.
Sounds like an old generation Xeon.
meanwhile, the same code runs less than 2.0 seconds on a AMD Athlon
2000+ box which runs freebsd 6.1 and gcc 3.4.4
Didn't AMD have much better floating-point than Intel during that generation
of CPUs?
why?
Compare the results from visual studio and gcc, both on Windows, both on the
same box, before you conclude there's something slow about vs2005.
thanks in advance.