https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62237
Bug ID: 62237 Summary: ostream single character printing is slower than fprintf with "%c". Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: mickey.veksler at gmail dot com Created attachment 33383 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33383&action=edit ostream vs. fprintf I have tried to write a micro-benchmark to compare the performance of the ostream and FILE interfaces. It turns out that GCC's ostream is performing quite well except in one case: out << ch; It takes almost 2.5 times the wall-time of the fprintf(out, "%c", ch) version (Please see the attached files). This does not make sense to me. Even worse, the fprintf version takes only 60% CPU instead of the 99% of the fprintf version. In order not to make you follow my analysis, which is possibly wrong, I do not add more of my results. I would say that from my analysis it seems that it should be relatively easy to speed-up this case, significantly.