News for hackers. Stuff that matters.
Re:Replacing JavaScript Hot Path with WebAssembly by robko on Friday February 15, 2019 @03:05AM (#19169271)
I get 60ms in C. But in your code, the compiler might decide to remove most of the code since b is not used after being calculated. I checked the assembly code and it does not seem to be the case here, but it's still something to be aware of.
Re:Replacing JavaScript Hot Path with WebAssembly by acqq on Friday February 15, 2019 @03:12AM (#19169297)
> I get 60ms in C

OK, I get cca 80ms for my run with the parameter 1 on my main computer, and 200ms on N3150 Celeron.

> b is not used after being calculated

Earlier, I've never seen that any C compiler optimizes away the call to the allocator and the access to the so allocated arrays. Maybe it's different now? Hm, dead code elimination... I guess a random init of the few values before and read and print of a few values after the loop must be always safe... Now that I think, also filling the array with zeroes before.