Friday, August 30, 2013

Speed-up Type equality comparison

What is the fastest way to compare two System.Type objects and generally any objects with reference equality applied?
See my results for 5 * 1000 * 1000 comparisons:




And the winner is: ReferenceEquals(type1, type2) || type1.Equals(type2).
Yep, I think this approach will benefit any custom key-value map where key is Type.
Those IoC guys are good candidates.

No comments:

Post a Comment