Skip to content

tmikov/linebench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

linebench

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

Building

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

Results

On a test machine:

Method

time

factor

C gets

0.590s

1x

C++ iostreams

0.295s

0.51x

FLEX scanner

0.782s

1.33x

C GNU readline

0.474s

0.80x

Python

1.985s

3.3x

NodeJS

1.089s

1.86x

About

Benchmarks for reading a text file line by line

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors