------- Comment #7 from redi at gcc dot gnu dot org  2010-09-07 19:50 -------
(In reply to comment #0)
> Calling ios::sync_with_stdio(false) before the loop start reduces the time per
> line to around 0.3us, on par with fgets(). This suggests that the problem is
> with the stdio synchronisation code.

It's well known (though maybe not well enough) that you should use
sync_with_stdio(false) to get good performance, unless you specifically need
the synchronisation.

(In reply to comment #4)
> Benchmarking on Solaris indicates that cin.getline() takes only 1us per
> iteration there, but I don't think the source code is available, so it's hard
> to provide details. 

If you mean the classic iostreams provided with Sun Studio (rather than GCC on
Solaris or something else) then that stream library is not standard-conforming
and you're comparing apples and oranges.  If you mean the STLport iostreams
provided with Sun Studio and enabled by -library=stlport4, the source is
available, but I'd be surprised if you see a significant speed difference.



Reply via email to