3 ms·
I think the problem is that it's using doubles, which JavaScript VMs feel free to optimise to ints. If I change the C code to long, I get the following: ma
by mpweiher 10y ago
I think the problem is that it's using doubles, which JavaScript VMs feel free to optimise to ints. If I change the C code to long, I get the following:
marcel@sarek[tmp]cc -Os sumints.c && ./a.out
49999995000000
Elapsed time: 0.000031 millis
The original:
marcel@sarek[tmp]cc -Os orig.c && ./a.out
49999995000000
Elapsed time: 8.276664 millis
That's a factor 266989 difference, if anyone cares :)