There's little difference. As always, if you're in doubt, profile - but I severely doubt you'll find anything interesting.
Static methods have three main advantages:
- No need to pass the implicit
this
- No virtual method calls
- No null-checking
Virtual method calls are avoided by not using the virtual
keyword and by not implementing interfaces. They are also evaluated in runtime and optimized away if possible.
Passing this
may be tricky for struct
s, but that's not how you'd usually implement a singleton. For a normal reference type, this is likely a simple pass-by-register reference.
The last point should also be obvious - due to the contracts in C#, if you try to call a method on a null
reference, you're supposed to get a NullReferenceException
- even if the method doesn't actually use this
at all.
However, performance isn't the only useful metric. If you think about it, static classes and static methods are little different from functional modules and functions. I think this is what the original article is alluding to the most - if done right, functional programming is a lot simpler than trying to fit your code into some arbitrarily defined classes. I'd assume that while there's plenty of static methods (functions), there's few static fields - and state changes can be tricky to manage and understand, if they get out of hand. This applies doubly for shared state, and you'd be hard pressed to find some state that is more shared than a public static field.
Again - performance is just one thing. Software development is a balancing act, and it doesn't do to focus on one metric. If you focus too much on (low level) performance, you might be missing out on maintenance and readability, and even on high level performance optimizations. If it's crucial to avoid overheads, go ahead - use static fields and static methods. If you need to handle 10k requests in parallel, you'll likely need a lot of low-level optimizations. But make sure you know it's usually a trade-off.