This tests different line-reading implementations in Node, Python and Nim.
- Nobody agrees on what a "line" is :) Except
wc
andpython
- Python is fastest, Node next, Nim last
Output from running make
:
---hugebin.txt---
wc -l hugebin.txt
1444473 hugebin.txt
time node reader.js hugebin.txt
hugebin.txt 1844188
2.18 real 2.13 user 0.11 sys
time ./myreader hugebin.txt
hugebin.txt 1444473
5.13 real 5.09 user 0.03 sys
time ./builtinreader hugebin.txt
hugebin.txt 279
0.00 real 0.00 user 0.00 sys
time python reader.py hugebin.txt
hugebin.txt 1444473
0.50 real 0.42 user 0.05 sys
---hugestr.txt---
wc -l hugestr.txt
2078017 hugestr.txt
time node reader.js hugestr.txt
hugestr.txt 3095841
0.65 real 0.63 user 0.08 sys
time ./myreader hugestr.txt
hugestr.txt 2078017
5.11 real 5.06 user 0.03 sys
time ./builtinreader hugestr.txt
hugestr.txt 3085918
5.01 real 4.96 user 0.03 sys
time python reader.py hugestr.txt
hugestr.txt 2078017
0.64 real 0.56 user 0.05 sys
As a table:
program | inputfile | time | line count |
---|---|---|---|
wc | hugebin.txt | 1444473 | |
reader.js | hugebin.txt | 2.18 | 1844188 |
Nim (custom proc) | hugebin.txt | 5.13 | 1444473 |
Nim (builtin proc) | hugebin.txt | 0 (failed) | 279 |
reader.py | hugebin.txt | 0.5 | 1444473 |
wc | hugestr.txt | 2078017 | |
reader.js | hugestr.txt | 0.65 | 3095841 |
Nim (custom proc) | hugestr.txt | 5.11 | 2078017 |
Nim (builtin proc) | hugestr.txt | 5.01 | 3085918 |
reader.py | hugestr.txt | 0.64 | 2078017 |