A collection of simple benchmarks for reading a text file line by line and printing it. The techniques used are supposed to be easy for each corresponding language/ environment. The results are surprising.
-
C++ iostreams and std::getline()
-
stdio gets/puts
-
GNU readline
-
A scanner generated by FLEX
-
Python
It has only been tested under MacOSX but it is expected it will work without any modification under Linux. Windows is not supported, though it could probably work under Cygwin. Contributions improving portability are welcome.
It requires CMake v2.8 or later. To build, in the source directory:
mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. make
Then to run, from within the build directory we just created:
../run-bench.sh .. sample-input.txt