------- 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