views:

59

answers:

2

I know that a class library compiled in 'Release' mode will run faster and more efficiently than one compiled in 'Debug' mode, but does anyone know to what extent?

EDIT: This is for a .net dll.

+1  A: 

It definitely depends on the sort of code. If the program is mostly a series of calls to existing code (in the CLR or elsewhere), then optimizing it will have little impact. But if it does significant processing, such as looping over data to calculate a hash, then it can be much faster, easily the factor of two mentioned by kingchris.

Keep in mind that Debug/Release is a little odd with .NET, in that it's a flag that affects JIT compilation. This means that Release code run under a debugger is, by default, treated as Debug code, and is therefore not optimized. Check your debugger options if this disturbs you.

Steven Sudit
A: 

When you're using a language that depends/relies on optimizations, such as C++/CLI, the difference may easily be a factor 10. This is because the IL generated will be already be slower, and running this IL in a debugger imposes a penalty on top of that.

MSalters
It may well be that it's not the overhead of the debugger, but that JIT non-optimization feature that I mentioned.
Steven Sudit