This code snippet compares the speed of reading lines of text from standard input.
Sample output:
> make test
clang++ -O4 -stdlib=libc++ -o readlines.clang readlines.cc
g++ -O3 -o readlines.gcc readlines.cc
./makebigfile
900...800...700...600...500...400...300...200...100...0...finished
900...800...700...600...500...400...300...200...100...0...finished
./readlines.py < bigfile
Read 29000000 lines in 7 seconds. LPS: 4142857
./readlines.clang < bigfile
Read 29000000 lines in 13 seconds. LPS: 2230769
./readlines.gcc < bigfile
Read 29000000 lines in 3 seconds. LPS: 9666666
>