Optimizing VB .net code

Here is a compiled list of things to look at when optimizing performance critical VB .net code.

  • Exceptions are slow
  • Use sealed methods, i.e. avoid virtual calls
  • Avoid Calls to Interface Methods
    Here’s another simple optimization tip: Calling a method through a secondary interface is
    slower than calling the same method in the main class interface.
  • Use Value Types, But Beware of Boxing
  • Implement the Dispose/Finalize Pattern:
    https://rcpmag.com/Articles/2002/08/01/Speed-Up-Your-VBNET-Code.aspx?Page=3
  • Option Compare Binary, strict and explicit
  • +=, AndAlso, etc
  • Avoid requalification and do property caching
  • Minimize the number of loops inside a Try block, and minimize the number of Try blocks inside
    a loop. A long loop could amplify the overhead of structured exception handling.
  • Use precompiling

Leave a Reply

Your email address will not be published. Required fields are marked *