In libstdc++ 4.4.3-4ubuntu5, getline() is extremely slow, taking around 23us of
user time per line on an Intel T9300 processor. By contrast, fgets() takes
about 0.3us per line.
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.
--
Summary: ifstream::getline() is extremely slow
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tstarling at wikimedia dot org
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45574