News for hackers. Stuff that matters.
Re:Beating C with one line of Brainfuck by readingnews on Sunday November 24, 2019 @03:50PM (#21623286)
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:Beating C with one line of Brainfuck by re on Sunday November 24, 2019 @04:02PM (#21623382)
Could 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

Re:Beating C with one line of Brainfuck by kiwec on Monday November 25, 2019 @02:11AM (#21626073)
For 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.
Re:Beating C with one line of Brainfuck by labawi on Monday November 25, 2019 @04:25AM (#21626609)
I 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.
Re:Beating C with one line of Brainfuck by klyrs on Sunday November 24, 2019 @05:43PM (#21624001)
For 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.

Re:Beating C with one line of Brainfuck by shakna on Monday November 25, 2019 @02:15AM (#21626086)
> 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

Re:Beating C with one line of Brainfuck by sicariusnoctis on Monday November 25, 2019 @08:51AM (#21628077)
Wait... is that a Sourcehut user in the wild?
Re:Beating C with one line of Brainfuck by shakna on Monday November 25, 2019 @09:07PM (#21635055)
Of 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.
Re:Beating C with one line of Brainfuck by yitchelle on Sunday November 24, 2019 @05:08PM (#21623782)
To 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.
Re:Beating C with one line of Brainfuck by sharedfrog on Sunday November 24, 2019 @05:32PM (#21623932)
You can manually clear the cache:

`echo 3 | sudo tee /proc/sys/vm/drop_caches`

Re:Beating C with one line of Brainfuck by gberger on Sunday November 24, 2019 @06:43PM (#21624332)
But the file is loaded in cat, which isn't timed
Re:Beating C with one line of Brainfuck by icebraining on Sunday November 24, 2019 @07:04PM (#21624443)
But the timed program still has to wait for cat to load the file. Both programs are launched (almost) simultaneously by the shell.
Re:Beating C with one line of Brainfuck by eMSF on Sunday November 24, 2019 @08:25PM (#21624755)
The 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).