fstream ./. fstream.h 
Author Message
 fstream ./. fstream.h

Hi everbody,
when I used the standard library with the fstream include,
I noticed that the code became slower. TrueTime analyzing
showed me that a fgetc function is called for each byte of
the buffer I wanted to read (see code sample below).
If I use the old fstream.h includes everything is 10 times
faster without these fgetc calls.
What's the reason for that behaviour and how can I avoid
it ?
Thank you
Ewald

  :
 char buffer[100000] ;
 ifstream fin ;
 fin.open ("MyFile.txt",ios::binary) ;
 fin.read(buffer,100000) ;
 fin.close () ;
  :



Sun, 05 Dec 2004 21:19:49 GMT  
 fstream ./. fstream.h


Quote:
> when I used the standard library with the fstream include,
> I noticed that the code became slower. TrueTime analyzing
> showed me that a fgetc function is called for each byte of
> the buffer I wanted to read (see code sample below).
> If I use the old fstream.h includes everything is 10 times
> faster without these fgetc calls.
> What's the reason for that behaviour

Bug.

Quote:
>                                      and how can I avoid
> it ?

Fix the bug. See http://www.dinkumware.com/vc_fixes.html.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com



Sun, 05 Dec 2004 22:37:02 GMT  
 fstream ./. fstream.h

Quote:
>Fix the bug. See http://www.dinkumware.com/vc_fixes.html.

Making the changes in the fstream include file doesn't
seem to fix the problem.
Do have to use your updated libraries also ?

Regards
Ewald K. Rieger



Sun, 05 Dec 2004 23:28:06 GMT  
 fstream ./. fstream.h


Quote:
> >Fix the bug. See http://www.dinkumware.com/vc_fixes.html.

> Making the changes in the fstream include file doesn't
> seem to fix the problem.

See the caveat about linking statically, to avoid getting old code
from DLLs.

Quote:
> Do have to use your updated libraries also ?

No, but that's one way to get an updated DLL.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com



Mon, 06 Dec 2004 00:51:16 GMT  
 fstream ./. fstream.h
Hi fellows,
I also made some investigation & found the fastest way of  reading that:
Look at the program below, notice, that "using namespace std", shouldn't
appear:

#include <windows.h>
#include <strstream>
#include <fstream.h>
#include <fstream>

static char strFileName[] = "d:\\delme.html";
int main()
{
char buffer[100000] ;
if (FILE* fp = fopen(strFileName, "rb"))
{
LARGE_INTEGER li, li1;
QueryPerformanceCounter(&li);
int Size = fread(buffer, 1, 100000, fp);
fclose(fp);
std::istrstream is(buffer, Size);
is.read(buffer, 100000);
QueryPerformanceCounter(&li1);
cout << (li1.LowPart - li.LowPart) << endl;

Quote:
}

{
ifstream is(strFileName);
if (is)
{
LARGE_INTEGER li, li1;
QueryPerformanceCounter(&li);
is.read(buffer, 100000);
QueryPerformanceCounter(&li1);
cout << (li1.LowPart - li.LowPart) << endl;
Quote:
}
}

{
std::ifstream is(strFileName);
if (is)
{
LARGE_INTEGER li, li1;
QueryPerformanceCounter(&li);
is.read(buffer, 100000);
QueryPerformanceCounter(&li1);
cout << (li1.LowPart - li.LowPart) << endl;
Quote:
}
}
return 0;
}



Mon, 06 Dec 2004 18:15:13 GMT  
 fstream ./. fstream.h

Ok. I missed that part.
Also bought the Dinkum library meanwhile and made a first
test. Looks good so far. Great to get rid of these
stupid /W4 warnings.

Regards
Ewald K. Rieger

Quote:
>-----Original Message-----

message

>> >Fix the bug. See

http://www.dinkumware.com/vc_fixes.html.
Quote:

>> Making the changes in the fstream include file doesn't
>> seem to fix the problem.

>See the caveat about linking statically, to avoid getting
old code
>from DLLs.

>> Do have to use your updated libraries also ?

>No, but that's one way to get an updated DLL.

>P.J. Plauger
>Dinkumware, Ltd.
>http://www.dinkumware.com

>.



Tue, 07 Dec 2004 14:56:28 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. bug in fstream? (works with fstream.h)

2. pb with replacing <fstream.h> by <fstream>

3. <fstream.h> and <fstream> chaos

4. <fstream.h> or <fstream>

5. #include <fstream> or <fstream.h>?

6. <fstream> vs <fstream.h>

7. Wrapping Unmanaged Class with std::fstream object fails

8. Fstream Problems using VC++ 4

9. fstream.h error!

10. fstream, FILE* and errno

11. STL::fstream or ATL::CAtlFile?

12. Problem using fstream in a library...

 

 
Powered by phpBB® Forum Software