Subscribe to get access
Read more of this content about code performance when you subscribe today.
FrozenSet Lookup Performance
The typical method to look up an item in a FrozenSet collection is by using TryGetValue(), as demonstrated in the example below:
_ = collection.TryGetValue(person, out var result);
Next, let’s compare the TryGetValue() method for a FrozenSet, ImmutableHashSet, and HashSet, as well as performing a lookup in a List using a LINQ Lambda expression.
Benchmark Results
As you can see in these results, HashSet and ImmutableHashSet are slightly more performant than FrozenSet. Additionally, FrozenSet is 22 times faster than performing a lookup in a List using a LINQ lambda expression.


Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks
Make a one-time donation
Make a monthly donation
Make a yearly donation
Choose an amount
Or enter a custom amount
Your contribution is appreciated.
Your contribution is appreciated.
Your contribution is appreciated.
DonateDonate monthlyDonate yearlyIf you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave
© The information in this article is copywritten and cannot be preproduced in any way without express permission from David McCarter.
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.

