C file IO faster than C++ file IO?

Started by
41 comments, last by Spearhawk 21 years, 1 month ago
It has been awhile, but seems when I tested streams were signficantly slower even when doing large reads. Overall it didn''t seem enough to matter. The reason being that you spend very little of your time in a game doing I/O. Doing that I/O in big bursts and making the user wait while you do it is a choice you make. So you are going to choose to do that and then worry about which method is faster? I don''t get the point of that.
Keys to success: Ability, ambition and opportunity.
Advertisement
I always found C++ iostreams to be slightly slower and slightly larger (due to the linkage requirements) than using stdio ''equivalents'', but you have to remember that the iostreams potentially do a lot more than stdio does. Iostreams perform a lot of character conversion and the like which many game applications will not need. Those who truly do have performance problems should consider streambufs or specifically filebufs instead. See also here.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
C++ is Slower than C!

What? Me no understand.

C and C++ are both programming languages. How can they have a speed, let alone how can you compare their ''speed''.

You seem to be talking about speed of execution, which is dependent on the machine code instructions produced by a compiler. This then is down to the particular compiler and the methods employed by the programmer.

You can''t make generalisations like this. If you have a method that is faster, then fine. Test it, measure it, prove it.

As a side note, I read somewhere that the Win32 CreateFile/... functions are marginally faster than fread because fread actually wraps the Win32 functions. It could be all baloney though, someone should test it.

This topic is closed to new replies.

Advertisement