Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "Optimize code" checkbox in Visual Studio. What exactly does it do?

Tags:

The Build tab of the Project Properties in Visual Studio 2005/2008 contains the "Optimize code".

The documentation states that it "... enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient."

  1. My question is why should I NOT have it on?
  2. Why is it not on by default?
  3. What does it actually do?
like image 501
AngryHacker Avatar asked Aug 21 '09 22:08

AngryHacker


People also ask

What does optimize code do in Visual Studio?

The Optimize option enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient.

What does it mean to Optimise code?

First of all, what is code optimization? Often, when we define it, we assume that we want code to perform better. We say that code optimization is writing or rewriting code so a program uses the least possible memory or disk space, minimizes its CPU time or network bandwidth, or makes the best use of additional cores.

How do you optimize a program code?

Optimize Program Algorithm For any code, you should always allocate some time to think the right algorithm to use. So, the first task is to select and improve the algorithm which will be frequently used in the code. 2. Avoid Type Conversion Whenever possible, plan to use the same type of variables for processing.


1 Answers

  1. You wouldn't want this on for a debug built, as it makes stepping through code harder as the actual code that is running may not properly reflect what you have written (since some lines will be optimized out)

  2. It is not on by default for DEBUG builds for the above reason, it should be enabled by default on release builds

  3. It performs optimizations such as dynamic inlining and removing unneeded local variables. Any sort of optimization that can be decided upon at compile time.

like image 167
LorenVS Avatar answered Sep 23 '22 08:09

LorenVS