A colleague of mine just told me that C++ iostream is typically an order of magnitude slower than printf. His example shows that printing out a string like “%s\t%d\tabc\t%s\t%s\n” with C++ iostream is 3 times slower than printf in Perl! This observation agrees my experience, although I have never done any benchmark. I abandoned iostream after I tried it the first time in my program.
Update: In another test, C++ iostream is ~30% slower, which is not too bad. Anyway, be aware that C++ iostream can be very slow in some cases. This thread also provides helpful information.
Leave a Reply