This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/45574] ifstream::getline() is extremely slow
- From: "tstarling at wikimedia dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Sep 2010 02:36:47 -0000
- Subject: [Bug libstdc++/45574] ifstream::getline() is extremely slow
- References: <bug-45574-19663@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from tstarling at wikimedia dot org 2010-09-08 02:36 -------
Created an attachment (id=21732)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21732&action=view)
100000 lines, 500 bytes per line
Test file attached as requested, compressed with gzip. Test code follows.
getline-test.cpp
#include <iostream>
int main(int argc, char** argv) {
char buffer[65536];
while (std::cin.getline(buffer, sizeof(buffer), '\n'));
return 0;
}
fgets-test.cpp:
#include <stdio.h>
int main(int argc, char** argv) {
char buffer[65536];
while (fgets(buffer, sizeof(buffer), stdin));
return 0;
}
$ time ./fgets-test < 500x100k.txt
real 0m0.076s
user 0m0.040s
sys 0m0.032s
$ time ./getline-test < 500x100k.txt
real 0m2.727s
user 0m2.672s
sys 0m0.028s
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45574