why is my iostream program so much slower than equivalent cstdio program?

D

Dave O'Hearn

Adam said:
I also tend to send debugging information to std::cerr instead
of std::cout. It makes it easier to debug filters, and (correct
me if I'm wrong) std::cerr isn't buffered. (OTOH, I generally
use std::endl with std::cerr anyway, so it wouldn't bite me if
it were.)

Correct, std::cerr isn't buffered. You may want to consider std::clog
instead, though. It writes to the same destination as std::cerr, but is
buffered. Using it properly can lead to many fewer flush operations
than using std::cerr, but you do have to remember to flush at the end
of every line. This is easy if you use a wrapper around the stream
though; I have one that inserts timestamps and flushes at the end of a
line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top