Benefits of 'Optimize code' option in Visual Studio build

g t picture g t · Mar 15, 2010 · Viewed 33.1k times · Source

Much of our C# release code is built with the 'Optimize code' option turned off. I believe this is to allow code built in Release mode to be debugged more easily.

Given that we are creating fairly simple desktop software which connects to backend Web Services, (ie. not a particularly processor-intensive application) then what if any sort of performance hit might be expected?

And is any particular platform likely to be worse affected? Eg. multi-processor / 64 bit.

Answer

Eric Lippert picture Eric Lippert · Mar 15, 2010

You are the only person who can answer the "performance hit" question. Try it both ways, measure the performance, and see what happens. The hit could be enormous or it could be nonexistant; no one reading this knows whether "enormous" to you means one microsecond or twenty minutes.

If you're interested in what optimizations are done by the C# compiler -- rather than the jitter -- when the optimize switch is on, see:

http://blogs.msdn.com/ericlippert/archive/2009/06/11/what-does-the-optimize-switch-do.aspx