|
|
|
|
|
by wzdd
827 days ago
|
|
Simply compiling it with -O3 produces something which completes in half the time of the JavaScript version (350ms for C, 750ms for JS), so perhaps that. Edit for Twirrim: on this system (Ryzen 7, gcc 11): "-O3": 350ms; "-O3 -march=native": 208ms; "-O2": 998ms; "-O2 -march=native": 1040ms. Edit 2: Interestingly, changing the C from float to double produces a 3.5x speedup, taking the time elapsed (with "-O3 -march=native") to 58ms, or about 12x faster than JS. This also makes what it's computing closer to the JavaScript version. |
|
No flags: 1843ms
-march=native: 2183 ms
-O2: 423 ms
-O2 -march=native: 250 ms
-O3: 425 ms
-O3 -march=native: 255 ms
O3 doesn't seem to be helping in my case.