Wednesday, September 19, 2007

Conditional("DEBUG") and Compiler Optimizations

OK... One interesting aside:

 ifdebug-8

See, how compiler had optimized the ENTIRE constructor away?  This is what is so very powerful.  Because Conditional("DEBUG") statements disappear on a RELEASE build, the compiler is free to optimize your code in ways it sees fit.

The results of compiling with optimizations  turned off:

 c:\>csc /optimize- /t:library ifdebug.cs

 

ifdebug-9

Here the compiler preserves your empty constructor.  We'll touch upon these points once again in forthcoming posts.

No comments: