3 ms·
To be fair for the C version: The linked code [1] doesn't really look like "decades of optimized C" to me. More like a straightforward implementation of this, w
by Matthias247 7y ago
To be fair for the C version: The linked code [1] doesn't really look like "decades of optimized C" to me. More like a straightforward implementation of this, which had been likely had not seen many updates for decades.
It could probably gain performance by playing around with input buffer sizes and trying to make use of vectorized instructions (the compiler might try to auto-vectorize the lops, but there is no guarantee).
[1] https://opensource.apple.com/source/text_cmds/text_cmds-68/wc/wc.c.auto.html https://opensource.apple.com/source/text_cmds/text_cmds-68/w...
- saagarjha 7y ago> the compiler might try to auto-vectorize the lops It does on my computer! The wc binary on my machine has movaps instructions.
- abainbridge 7y agoExactly this. I see this as "Simplest possible C code beats carefully hand optimized Haskell".