help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ 3.x slower than 2.95 for i/o


From: Mark Goldman
Subject: g++ 3.x slower than 2.95 for i/o
Date: Tue, 17 May 2005 18:04:47 -0700

I am running the following code on a Sun Solaris  OS 5.7 machine.

I am compiling it with both g++ 2.95 and g++ 3.3.2, using the command:

g++ -O3 -o z z.cc

where z.cc is the following:





#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

main(int argc, char** argv) {

   int i = 1;
   double d1 = 2.3;
   double d2 = 3.4;

   ofstream ofstr("zout");

   for (int counter = 0; counter < 300000; counter++) {
      ofstr << i << d1 << d2 << '\n';
   }

   ofstr.close();

}





for the 2.95 version, the job takes 2.3 seconds to run
for the 3.3.2 version, the job takes 9.5 seconds to run

Thus g++ 2.95 is 4 times faster than g++ 3.3.2.

Is this normal?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]