5 ms·
Now that is just ridiculous! With O2 and O3 I get 0.03 seconds on average! I try to understand what could possibly mean all of the flags that get switched on wi
by bite_victim 11y ago
Now that is just ridiculous! With O2 and O3 I get 0.03 seconds on average! I try to understand what could possibly mean all of the flags that get switched on with optimizations from this page: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
I also wonder if Java has any kind of optimizations to experiment with.
- fsk 11y agoIf you don't put in ANY optimization flags, it puts in full debugging info, which slows things down a lot. I don't know anything about Java optimization.
- bite_victim 11y agoJava doesn't have any optimization flags and the debugging info slowdown makes sense I suppose. That is the exact difference between them, GCC with -O3 is almost 100x faster in another test I just did: 10s for Java, 0.1 for C. When you turn off the optimization flags C jumps right at the same 10s figure though. Really cool interesting stuff!
- fsk 11y agoThat's what I figured - a lot of people who say "Java is as fast as C" aren't doing proper compiler optimizations on their C. I suspected that was true, but I didn't spend the time on a proper test. -O2 or -O3 does some neat stuff like unrolling loops and inlining functions --fast_math is another one I use