When I was looking through the article (thank you for sharing it), I noticed that the .Contains test uses a closure that creates a new array each iteration of .Count.
While it is something that happens even in code sent to me for review from time to time, I don't think that it paints the full picture. I think it would be useful to also show the impact of only creating the array once and then using .Contains on that.
When classes have static read-only tables in them (say, for comparing data against a set of fixed values) there wouldn't be any allocation for the array itself, and in this case we can measure solely the performance of .Contains.
When I was looking through the article (thank you for sharing it), I noticed that the
.Containstest uses a closure that creates a new array each iteration of.Count.While it is something that happens even in code sent to me for review from time to time, I don't think that it paints the full picture. I think it would be useful to also show the impact of only creating the array once and then using
.Containson that.When classes have static read-only tables in them (say, for comparing data against a set of fixed values) there wouldn't be any allocation for the array itself, and in this case we can measure solely the performance of
.Contains.