C#/VB.NET Configuration - Do you know not to use debug compilation in production applications?

Updated by Brady Stroud [SSW] 1 year ago. See history

123
No component provided for introEmbed

In debug mode the compiler emits debug symbols for all variables and compiles the code as is. In release mode some optimizations are included:

  • unused variables do not get compiled at all
  • some loop variables are taken out of the loop by the compiler if they are proven to be invariants
  • code written under #debug directive is not included etc.

The rest is up to the JIT.

As per: C# debug vs release performance.

Image

❌ Figure: Bad Example

Image

✅ Figure: Good Example

We have a program called SSW Code Auditor to check for this rule.

Acknowledgements

Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star