4 ms·
I just wrote a very dumb implementation of wc and it’s easily twice as fast. I think the core issue is that wc is not a super optimized program. It is sufficie
by olliej 7y ago
I just wrote a very dumb implementation of wc and it’s easily twice as fast.
I think the core issue is that wc is not a super optimized program. It is sufficiently fast for most purposes and so hasn’t ever been improved.
- xrisk 7y agoCan you test it with GNU wc? I'm curious https://github.com/coreutils/coreutils/blob/master/src/wc.c https://github.com/coreutils/coreutils/blob/master/src/wc.c
- olliej 7y agoI’m comparing to Mac wc, which is apparently what they were testing against, and I was getting twice that perf without anything clever. That said I’ll try to post my horrifying impl to GitHub later :)
- olliej 7y agoHere is my super dumb implementation. Doesn't handle multibyte, doesn't handle stdin -- but I don't think the Haskell version did either, so I don't have a problem with that limit. https://github.com/ojhunt/wc https://github.com/ojhunt/wc It's the simplest thing that could obviously work, but its generally not tested beyond the most basic versions.