Thursday, August 23, 2007

Static can increase performance

How declaring methods as ‘Static’ can increase performance? By FxCop

  • Methods which do not access instance data or call instance methods can be marked as static (Shared in VB).
  • After doing so, the compiler will emit non-virtual call sites to these members which will prevent a check at runtime for each call that insures the current object pointer is non-null.
  • This can result in a measurable performance gain for performance-sensitive code.
  • In some cases, the failure to access the current object instance represents a correctness issue.

Thanks & Regards,

Arun Manglick || Tech Lead

No comments:

Post a Comment