Closed khalidsalomao closed 8 years ago
Do you have any bencnmarks that give some idea of how much better performance is with these changes?
The changes look pretty straight forward to me. Thanks for the submission.
The compiled getters and setters methods tends to be 10-15X faster.
In a quick and dirty benchmark with 5.000.000 iterations: Reflection took 2.610 ms Compiled method took 168 ms
Here is the code that you can open in LinqPad and test it! https://gist.github.com/khalidsalomao/facf4e1f5d61523dbd14
Review to remove the usage of
PropertyInfo.GetValue
andPropertyInfo.SetValue
in favor of a compiled methods by using Lambda Expression - a much faster way of dealing with reflection to get and set values. Also useStringComparer.Ordinal
for dictionary hash function with is faster than the default.