What does “Optimize Code” option really do in Visual Studio?

前端 未结 3 2073
礼貌的吻别
礼貌的吻别 2020-11-28 05:04

Name of the option tells something but what Visual Studio/compiler really do and what are the real consequences?

Edit: If you search google you can find this address

3条回答
  •  天涯浪人
    2020-11-28 05:53

    The short answer is: use -Ox and let the compiler do its job.

    The long answer: the effect of different kind of optimizations is impossible to predict accurately. Sometimes optimizing for fast code will actually yield smaller code than when optimizing for size. If you really want to get the last 0.01% of performance (speedwise or sizewise), you have to benchmark different combination of options.

    Also, recent versions of Visual Studio have options for more advanced optimizations such as link-time optimization and profile-guided optimization.

提交回复
热议问题