Operating System - Linux
1745786 Members
3660 Online
108722 Solutions
New Discussion

Some problems in using fstream class with aCC

 
LiJianfeng
Occasional Contributor

Some problems in using fstream class with aCC

This days, i am using fstream class with aCC, but have some problem below:

I wrote a realy simple program like this: read a testfile which have 1MByte, every time, it reads 8KByte.

If i use stdio.h, it will use 0.005 second, if i use fstream, it will use 0.4 second.

The version of aCC is aCC: HP ANSI C++ B3910B A.03.50

The operation system is: HP-UX n1 B.11.11 U 9000/800

I need help, thank you.
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Some problems in using fstream class with aCC

In general if you want performance you shouldn't be using iostreams. Especially with -AA.

There is a web page with some -AA performance concerns that may help:
http://h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,5520,00.html

Also:
There are three common techniques used by programmers for improving iostream
performance based on specific situations:

1) setting ios_base::sync_with_stdio(false)
Default syncronization with stdio is disabled.

2) setting cin.tie(0)
Unties the cin from other streams.

3) Avoiding endl and using '\n' instead
Endl flushes the output. This might be costly if the endl is
used often, since flush() might result in calling write().