hello
i have a program that is written by Borland C++Builder 6
it is a program for writing binary files using ofstream.
but when i ship this program to Borland C++Builder 2006/2007 and compile it,the run time of program increased very much.
for example you can test this standard code in both BCB 6 and BCB 2006 and see the resulted time.
the time of BCB 6 is very very better than BCB 2006
btw : i have used other methods such as windows API for writing the files but their time isn't as good as IOstreams time.

#include <fstream>
#include <iostream>
#include <DateUtils.hpp>

int n[100000];

for(int i=0; i<100000; i++) 
 n[i] = 1;

fstream out("test", ios::out | ios::binary);
if(!out) {
 ShowMessage("Cannot open file.");
 exit(0);
}

TTime t1=Time ();

 out.write((char *) &n, sizeof n);

TTime t2=Time ();
ShowMessage( MilliSecondsBetween(t1,t2));

out.close();

I don't have either of those compilers. Why don't you just write a simple little program that demonstrates the problem and that can be compiled by any compiler, then compare the output with the results on other compilers. This one for example: I'm using win32 api function QueryPerformanceCounter() below because the program runs too fast for clock() to produce any measurable results.

#include <fstream>
#include <iostream>
#include <windows.h>
using namespace std;

int n[100000];
int main()
{
    
for(int i=0; i<100000; i++) 
 n[i] = 1;

fstream out("test", ios::out | ios::binary);
if(!out) {
 cout << "Cannot open file.";
 exit(0);
}

LARGE_INTEGER t1, t2;
QueryPerformanceCounter(&t1);
cout << t1.QuadPart << " ";
 out.write((char *) &n, sizeof n);

QueryPerformanceCounter(&t2);
cout << t2.QuadPart << "\n";
cout << "milliseconds between = " << t2.QuadPart - t1.QuadPart << "\n";

out.close();
}

The output on my computer (Vista) using VC++ 2008 Express is. Note: The results are NOT in milliseconds, but just the difference in the high resulution performance counter values.

475833937637 475833946257
milliseconds between = 8620
Press any key to continue . . .

Now that I think about it, comparing the above values with compilers on different computers (such as yous and mine) will be of little to no value. But might help to demonstrate the differences among compilers on the same machine.

This article has been dead for over six months. Start a new discussion instead.