7 ms·
I wonder if Brainfuck wins by his 100th of a second since he already called a program with words.txt, and therefore it was already loaded into memory, thus savi
by readingnews 7y ago
I wonder if Brainfuck wins by his 100th of a second since he already called a program with words.txt, and therefore it was already loaded into memory, thus saving just a slice of time, as it would already be in the cache.
- re 7y agoCould also be that their version of wc is doing Unicode-aware counting by default; it could be a lot faster with LANG=C set in the environment. https://unix.stackexchange.com/a/96580 https://unix.stackexchange.com/a/96580
- kiwec 7y agoFor some reason, wc is even slower with LANG=C. cat words.txt | time wc -w 13018291 0.76 user 0.01 system 0:00.78 elapsed That's on the default wc build of void linux, and not in a proper benchmark environment, but that's still strange.
- labawi 7y agoI prefer setting LC_ALL=C for to be sure, though LANG may be sufficient, as running "LANG=C locale" confirms LC_CTYPE=C is set.
- yitchelle 7y agoTo avoid the caching bias, I think a fairer test condition would be to use multiple files and do it over a number of times. The lowest average time would be the winner.
- sharedfrog 7y agoYou can manually clear the cache: `echo 3 | sudo tee /proc/sys/vm/drop_caches`
- klyrs 7y agoFor a #shitpost, one need only observe the fastest run of program A being faster than the slowest run of program B, to declare A is faster than B. With a sufficiently powerful static evaluator, you could embed the input into the program and get an even faster runtime.
- shakna 7y ago> With a sufficiently powerful static evaluator, you could embed the input into the program and get an even faster runtime. If you feel the need to cheat, you could do something like I used for dumb_cat [0] and dump the resulting executables into a cache somewhere. [0] https://git.sr.ht/~shakna/dumb_cat https://git.sr.ht/~shakna/dumb_cat
- sicariusnoctis 7y agoWait... is that a Sourcehut user in the wild?
- shakna 7y agoOf course. I love what Drew has built. I'm much happier (as a paying customer) with it as a platform than most of the others.
- gberger 7y agoBut the file is loaded in cat, which isn't timed
- icebraining 7y agoBut the timed program still has to wait for cat to load the file. Both programs are launched (almost) simultaneously by the shell.
- eMSF 7y agoThe article only listed user and sys time usage, so technically that doesn't matter. That being said, in my experience those timings are not very accurate at this time scale; timing a program which takes just a few tenths to execute may report halving or doubling the user time between subsequent runs (and vice versa for systime).