3 ms·
Alternatively, here's my entry for "Beating C with 40 lines of C": https://pastebin.com/JzFfE5GB https://pastebin.com/JzFfE5GB $ time wc -w 100m 2266395 10
by jstanley 7y ago
Alternatively, here's my entry for "Beating C with 40 lines of C": https://pastebin.com/JzFfE5GB https://pastebin.com/JzFfE5GB
$ time wc -w 100m
2266395 100m
real 0m4.568s
$ cc -o wc wc.c
$ time ./wc 100m
2343390 100m
real 0m0.511s
Of course, it disagrees on the answer, because I just used 100M of random data and it doesn't care about wide characters. It gives the same answer as GNU on plain ASCII text.
It's not faster because it's better, it's faster because it is doing less.
- Quekid5 7y ago> It's not faster because it's better, it's faster because it is doing less. I can't recall who said it, but this reminds me of this idea: If you don't care about correctness then I can make it as fast as you like.
- glandium 7y agoAlternatively, here's my entry for "Beating GNU wc with GNU wc": $ dd if=/dev/urandom of=100m bs=1M count=100 2> /dev/null $ time wc -w 100m 2319144 100m real 0m4.543s user 0m4.512s sys 0m0.029s $ time env LC_CTYPE=C wc -w 100m 2308032 100m real 0m0.842s user 0m0.842s sys 0m0.000s Your program is faster, though.