10

That time when I wowed all my colleagues with C++-code that executed over 2.5x faster than theirs, without changing one line of code.

I guess they didn't know what -O2 does (or that it exists, for that matter).

Comments
  • 5
    Most programmers don't know about compiler flags because the IDE makes it essentially invisible :( and even if theres an option for all the flags, god forbid someone googled it or explored their IDE when they don't have to -_-
  • 1
    Guess what, me neither, is it like a compiler argument?
  • 1
    @Ranchu Precisely.
  • 0
    @Fakerlol does it work for most compilers or only certain ones?
  • 1
    @Ranchu Well I only ever used it with gcc, so I wouldn't know if it works with other compilers - at least with this specific flag.
    I'm pretty sure that all C/++ compilers worth their name have some sort of optimization routines built in, one just has to find out how to use them.

    Microsoft's has it, as you can change it through the properties of the project or with the corresponding flag (I think it was /O).

    Another tidbit: When using an IDE without a makefile, usually choosing Debug-Mode will compile with O0 and choosing Release-Mode will compile with O3. You can spot this in the compilers' output :)
  • 0
    @Fakerlol good to know, thanks
Add Comment