howto count lines - fast

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 30 17:13:46 PDT 2017


On 05/30/2017 01:02 PM, Nitram wrote:
> After reading
> https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i
> was wondering how fast one can do a simple "wc -l" in D.
>
> So i made a couple short implementations and found myself confronted
> with slow results compared to "/usr/bin/wc -l".
>
> How would a implementation look like in D, which is fast?
>

I could not make the D program come close to wc's performance when the 
data was piped from stdin. A typical run with Daniel Kozak's program:

$ time cat deleteme.txt | wc -l
5062176

real	0m0.086s
user	0m0.068s
sys	0m0.048s

$ time cat deleteme.txt | ./deneme
5062176

real	0m0.174s
user	0m0.152s
sys	0m0.072s

Ali



More information about the Digitalmars-d-learn mailing list