I am glad to see this participation on this issue :)
The hints about trying another compiler and std.mmfile turned out to be very effective.

Even this simple code is faster then my systems "wc -l" now:
void main() {
        import std.stdio;
        writeln(lcs("benchmark.dat"));
}

size_t lcs(string filename) {
        import std.mmfile;
        auto f = new MmFile(filename);
        auto data = cast(ubyte[]) f[];
        size_t c = 0;
        foreach(ref i ; data) {
                if (i == '\n') c++;
        }
        return c;
}

time wc -l ./benchmark.dat
10500000 ./benchmark.dat
wc -l ./benchmark.dat 0,06s user 0,03s system 99% cpu 0,089 total

time ./lcs
10500000
./lcs  0,05s user 0,01s system 99% cpu 0,061 total

Reply via email to