Frozen Collection in .NET 8




Date Added (UTC):

26 Apr 2024 @ 11:44

Date Updated (UTC):

26 Apr 2024 @ 14:55


.NET Version(s):

.NET 8

Tag(s):

#.Net8PerfImprovement #Collections


Added By:
Profile Image

Sri Lanka    
Tech Enthusiast | .Net | C# | Azure | AWS

Benchmark Results:





Benchmark Code:



using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;

[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    private const int itemsCount = 100_000;
    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.Range(0, itemsCount).ToDictionary(key => key);
    private ImmutableDictionary<int, int> _immutableDictionary = Enumerable.Range(0, itemsCount).ToImmutableDictionary(key => key);
   

    private HashSet<int> _hashSet = Enumerable.Range(0, itemsCount).ToHashSet();
    private ImmutableHashSet<int> _immutableHashSet = Enumerable.Range(0, itemsCount).ToImmutableHashSet();

    private FrozenDictionary<int, int> _frozenDictionary = Enumerable.Range(0, itemsCount).ToFrozenDictionary(key => key);
    private FrozenSet<int> _frozenSet = Enumerable.Range(0, itemsCount).ToFrozenSet();

    [Benchmark]
    public void TryGetValueDictionary()
    {
        _dictionary.TryGetValue(keyToFind, out _);
    }

    [Benchmark]
    public void TryGetValueImmutableDictionary()
    {
        _immutableDictionary.TryGetValue(keyToFind, out _);
    }

    [Benchmark]
    public void TryGetValueFrozenDictionary()
    {
        _frozenDictionary.TryGetValue(keyToFind, out _);
    }

    [Benchmark]
    public void TryGetValueHashSet()
    {
        _hashSet.TryGetValue(keyToFind, out _);
    }

    [Benchmark]
    public void TryGetValueImmutableHashSet()
    {
        _immutableHashSet.TryGetValue(keyToFind, out _);
    }

    [Benchmark]
    public void TryGetValueFrozenSet()
    {
        _frozenSet.TryGetValue(keyToFind, out _);
    }

    [Benchmark]
    public void CreateDictionary()
    {
        Dictionary<int, int> dictionary = Enumerable.Range(0, itemsCount).ToDictionary(key => key);
    }

    [Benchmark]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary<int, int> dictionary = Enumerable.Range(0, itemsCount).ToImmutableDictionary(key => key);
    }

    [Benchmark]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary<int, int> frozenDictionary = Enumerable.Range(0, itemsCount).ToFrozenDictionary(key => key);
    }

    [Benchmark]
    public void CreateList()
    {
        List<int> list = Enumerable.Range(0, itemsCount).ToList();
    }

    [Benchmark]
    public void CreateHashSet()
    {
        HashSet<int> hashSet = Enumerable.Range(0, itemsCount).ToHashSet();
    }

    [Benchmark]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet<int> hashSet = Enumerable.Range(0, itemsCount).ToImmutableHashSet();
    }

    [Benchmark]
    public void CreateFrozenSet()
    {
        FrozenSet<int> frozenSet = Enumerable.Range(0, itemsCount).ToFrozenSet();
    }
}

// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}
// .NET 8
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]

[NullableContext(1)]
[Nullable(0)]
[Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]
[MemoryDiagnoser(false)]
[RankColumn(NumeralSystem.Arabic)]
[MarkdownExporter]
public class FrozenCollection
{
    [Serializable]
    [CompilerGenerated]
    private sealed class <>c
    {
        [Nullable(0)]
        public static readonly <>c <>9 = new <>c();

        [Nullable(0)]
        public static Func<int, int> <>9__14_0;

        [Nullable(0)]
        public static Func<int, int> <>9__15_0;

        [Nullable(0)]
        public static Func<int, int> <>9__16_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_0;

        [Nullable(0)]
        public static Func<int, int> <>9__21_1;

        [Nullable(0)]
        public static Func<int, int> <>9__21_2;

        internal int <CreateDictionary>b__14_0(int key)
        {
            return key;
        }

        internal int <CreateImmutableDictionary>b__15_0(int key)
        {
            return key;
        }

        internal int <CreateFrozenDictionary>b__16_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_0(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_1(int key)
        {
            return key;
        }

        internal int <.ctor>b__21_2(int key)
        {
            return key;
        }
    }

    private const int itemsCount = 100000;

    private const int keyToFind = 500;

    private Dictionary<int, int> _dictionary = Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_0 ?? (<>c.<>9__21_0 = new Func<int, int>(<>c.<>9.<.ctor>b__21_0)));

    private ImmutableDictionary<int, int> _immutableDictionary = ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_1 ?? (<>c.<>9__21_1 = new Func<int, int>(<>c.<>9.<.ctor>b__21_1)));

    private HashSet<int> _hashSet = Enumerable.ToHashSet(Enumerable.Range(0, 100000));

    private ImmutableHashSet<int> _immutableHashSet = ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));

    private FrozenDictionary<int, int> _frozenDictionary = FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__21_2 ?? (<>c.<>9__21_2 = new Func<int, int>(<>c.<>9.<.ctor>b__21_2)));

    private FrozenSet<int> _frozenSet = FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));

    [Benchmark(39, "_")]
    public void TryGetValueDictionary()
    {
        int value;
        _dictionary.TryGetValue(500, out value);
    }

    [Benchmark(45, "_")]
    public void TryGetValueImmutableDictionary()
    {
        int value;
        _immutableDictionary.TryGetValue(500, out value);
    }

    [Benchmark(51, "_")]
    public void TryGetValueFrozenDictionary()
    {
        int value;
        _frozenDictionary.TryGetValue(500, out value);
    }

    [Benchmark(57, "_")]
    public void TryGetValueHashSet()
    {
        int actualValue;
        _hashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(63, "_")]
    public void TryGetValueImmutableHashSet()
    {
        int actualValue;
        _immutableHashSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(69, "_")]
    public void TryGetValueFrozenSet()
    {
        int actualValue;
        _frozenSet.TryGetValue(500, out actualValue);
    }

    [Benchmark(75, "_")]
    public void CreateDictionary()
    {
        Enumerable.ToDictionary(Enumerable.Range(0, 100000), <>c.<>9__14_0 ?? (<>c.<>9__14_0 = new Func<int, int>(<>c.<>9.<CreateDictionary>b__14_0)));
    }

    [Benchmark(81, "_")]
    public void CreateImmutableDictionary()
    {
        ImmutableDictionary.ToImmutableDictionary(Enumerable.Range(0, 100000), <>c.<>9__15_0 ?? (<>c.<>9__15_0 = new Func<int, int>(<>c.<>9.<CreateImmutableDictionary>b__15_0)));
    }

    [Benchmark(87, "_")]
    public void CreateFrozenDictionary()
    {
        FrozenDictionary.ToFrozenDictionary(Enumerable.Range(0, 100000), <>c.<>9__16_0 ?? (<>c.<>9__16_0 = new Func<int, int>(<>c.<>9.<CreateFrozenDictionary>b__16_0)));
    }

    [Benchmark(93, "_")]
    public void CreateList()
    {
        Enumerable.ToList(Enumerable.Range(0, 100000));
    }

    [Benchmark(99, "_")]
    public void CreateHashSet()
    {
        Enumerable.ToHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(105, "_")]
    public void CreateImmutableHashSet()
    {
        ImmutableHashSet.ToImmutableHashSet(Enumerable.Range(0, 100000));
    }

    [Benchmark(111, "_")]
    public void CreateFrozenSet()
    {
        FrozenSet.ToFrozenSet(Enumerable.Range(0, 100000));
    }
}

// .NET 8
.method public hidebysig 
    instance void TryGetValueDictionary () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 27 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x2050
    // Code size 20 (0x14)
    .maxstack 3
    .locals init (
        [0] int32
    )

    // sequence point: (line 42, col 9) to (line 42, col 51) in _
    IL_0000: ldarg.0
    IL_0001: ldfld class [System.Collections]System.Collections.Generic.Dictionary`2<int32, int32> FrozenCollection::_dictionary
    IL_0006: ldc.i4 500
    IL_000b: ldloca.s 0
    IL_000d: callvirt instance bool class [System.Collections]System.Collections.Generic.Dictionary`2<int32, int32>::TryGetValue(!0, !1&)
    IL_0012: pop
    // sequence point: (line 43, col 5) to (line 43, col 6) in _
    IL_0013: ret
}
// .NET 8
.method public hidebysig 
    instance void TryGetValueImmutableDictionary () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 2d 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x2070
    // Code size 20 (0x14)
    .maxstack 3
    .locals init (
        [0] int32
    )

    // sequence point: (line 48, col 9) to (line 48, col 60) in _
    IL_0000: ldarg.0
    IL_0001: ldfld class [System.Collections.Immutable]System.Collections.Immutable.ImmutableDictionary`2<int32, int32> FrozenCollection::_immutableDictionary
    IL_0006: ldc.i4 500
    IL_000b: ldloca.s 0
    IL_000d: callvirt instance bool class [System.Collections.Immutable]System.Collections.Immutable.ImmutableDictionary`2<int32, int32>::TryGetValue(!0, !1&)
    IL_0012: pop
    // sequence point: (line 49, col 5) to (line 49, col 6) in _
    IL_0013: ret
}
// .NET 8
.method public hidebysig 
    instance void TryGetValueFrozenDictionary () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 33 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x2090
    // Code size 20 (0x14)
    .maxstack 3
    .locals init (
        [0] int32
    )

    // sequence point: (line 54, col 9) to (line 54, col 57) in _
    IL_0000: ldarg.0
    IL_0001: ldfld class [System.Collections.Immutable]System.Collections.Frozen.FrozenDictionary`2<int32, int32> FrozenCollection::_frozenDictionary
    IL_0006: ldc.i4 500
    IL_000b: ldloca.s 0
    IL_000d: callvirt instance bool class [System.Collections.Immutable]System.Collections.Frozen.FrozenDictionary`2<int32, int32>::TryGetValue(!0, !1&)
    IL_0012: pop
    // sequence point: (line 55, col 5) to (line 55, col 6) in _
    IL_0013: ret
}
// .NET 8
.method public hidebysig 
    instance void TryGetValueHashSet () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 39 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x20b0
    // Code size 20 (0x14)
    .maxstack 3
    .locals init (
        [0] int32
    )

    // sequence point: (line 60, col 9) to (line 60, col 48) in _
    IL_0000: ldarg.0
    IL_0001: ldfld class [System.Collections]System.Collections.Generic.HashSet`1<int32> FrozenCollection::_hashSet
    IL_0006: ldc.i4 500
    IL_000b: ldloca.s 0
    IL_000d: callvirt instance bool class [System.Collections]System.Collections.Generic.HashSet`1<int32>::TryGetValue(!0, !0&)
    IL_0012: pop
    // sequence point: (line 61, col 5) to (line 61, col 6) in _
    IL_0013: ret
}
// .NET 8
.method public hidebysig 
    instance void TryGetValueImmutableHashSet () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 3f 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x20d0
    // Code size 20 (0x14)
    .maxstack 3
    .locals init (
        [0] int32
    )

    // sequence point: (line 66, col 9) to (line 66, col 57) in _
    IL_0000: ldarg.0
    IL_0001: ldfld class [System.Collections.Immutable]System.Collections.Immutable.ImmutableHashSet`1<int32> FrozenCollection::_immutableHashSet
    IL_0006: ldc.i4 500
    IL_000b: ldloca.s 0
    IL_000d: callvirt instance bool class [System.Collections.Immutable]System.Collections.Immutable.ImmutableHashSet`1<int32>::TryGetValue(!0, !0&)
    IL_0012: pop
    // sequence point: (line 67, col 5) to (line 67, col 6) in _
    IL_0013: ret
}
// .NET 8
.method public hidebysig 
    instance void TryGetValueFrozenSet () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 45 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x20f0
    // Code size 20 (0x14)
    .maxstack 3
    .locals init (
        [0] int32
    )

    // sequence point: (line 72, col 9) to (line 72, col 50) in _
    IL_0000: ldarg.0
    IL_0001: ldfld class [System.Collections.Immutable]System.Collections.Frozen.FrozenSet`1<int32> FrozenCollection::_frozenSet
    IL_0006: ldc.i4 500
    IL_000b: ldloca.s 0
    IL_000d: callvirt instance bool class [System.Collections.Immutable]System.Collections.Frozen.FrozenSet`1<int32>::TryGetValue(!0, !0&)
    IL_0012: pop
    // sequence point: (line 73, col 5) to (line 73, col 6) in _
    IL_0013: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateDictionary () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 4b 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x2110
    // Code size 49 (0x31)
    .maxstack 8

    // sequence point: (line 78, col 9) to (line 78, col 100) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: ldsfld class [System.Runtime]System.Func`2<int32, int32> FrozenCollection/'<>c'::'<>9__14_0'
    IL_0010: dup
    IL_0011: brtrue.s IL_002a

    IL_0013: pop
    IL_0014: ldsfld class FrozenCollection/'<>c' FrozenCollection/'<>c'::'<>9'
    IL_0019: ldftn instance int32 FrozenCollection/'<>c'::'<CreateDictionary>b__14_0'(int32)
    IL_001f: newobj instance void class [System.Runtime]System.Func`2<int32, int32>::.ctor(object, native int)
    IL_0024: dup
    IL_0025: stsfld class [System.Runtime]System.Func`2<int32, int32> FrozenCollection/'<>c'::'<>9__14_0'

    IL_002a: call class [System.Collections]System.Collections.Generic.Dictionary`2<!!1, !!0> [System.Linq]System.Linq.Enumerable::ToDictionary<int32, int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>, class [System.Runtime]System.Func`2<!!0, !!1>)
    IL_002f: pop
    // sequence point: (line 79, col 5) to (line 79, col 6) in _
    IL_0030: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateImmutableDictionary () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 51 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x2142
    // Code size 49 (0x31)
    .maxstack 8

    // sequence point: (line 84, col 9) to (line 84, col 118) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: ldsfld class [System.Runtime]System.Func`2<int32, int32> FrozenCollection/'<>c'::'<>9__15_0'
    IL_0010: dup
    IL_0011: brtrue.s IL_002a

    IL_0013: pop
    IL_0014: ldsfld class FrozenCollection/'<>c' FrozenCollection/'<>c'::'<>9'
    IL_0019: ldftn instance int32 FrozenCollection/'<>c'::'<CreateImmutableDictionary>b__15_0'(int32)
    IL_001f: newobj instance void class [System.Runtime]System.Func`2<int32, int32>::.ctor(object, native int)
    IL_0024: dup
    IL_0025: stsfld class [System.Runtime]System.Func`2<int32, int32> FrozenCollection/'<>c'::'<>9__15_0'

    IL_002a: call class [System.Collections.Immutable]System.Collections.Immutable.ImmutableDictionary`2<!!1, !!0> [System.Collections.Immutable]System.Collections.Immutable.ImmutableDictionary::ToImmutableDictionary<int32, int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>, class [System.Runtime]System.Func`2<!!0, !!1>)
    IL_002f: pop
    // sequence point: (line 85, col 5) to (line 85, col 6) in _
    IL_0030: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateFrozenDictionary () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 57 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x2174
    // Code size 50 (0x32)
    .maxstack 8

    // sequence point: (line 90, col 9) to (line 90, col 118) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: ldsfld class [System.Runtime]System.Func`2<int32, int32> FrozenCollection/'<>c'::'<>9__16_0'
    IL_0010: dup
    IL_0011: brtrue.s IL_002a

    IL_0013: pop
    IL_0014: ldsfld class FrozenCollection/'<>c' FrozenCollection/'<>c'::'<>9'
    IL_0019: ldftn instance int32 FrozenCollection/'<>c'::'<CreateFrozenDictionary>b__16_0'(int32)
    IL_001f: newobj instance void class [System.Runtime]System.Func`2<int32, int32>::.ctor(object, native int)
    IL_0024: dup
    IL_0025: stsfld class [System.Runtime]System.Func`2<int32, int32> FrozenCollection/'<>c'::'<>9__16_0'

    IL_002a: ldnull
    IL_002b: call class [System.Collections.Immutable]System.Collections.Frozen.FrozenDictionary`2<!!1, !!0> [System.Collections.Immutable]System.Collections.Frozen.FrozenDictionary::ToFrozenDictionary<int32, int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>, class [System.Runtime]System.Func`2<!!0, !!1>, class [System.Runtime]System.Collections.Generic.IEqualityComparer`1<!!1>)
    IL_0030: pop
    // sequence point: (line 91, col 5) to (line 91, col 6) in _
    IL_0031: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateList () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 5d 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x21a7
    // Code size 18 (0x12)
    .maxstack 8

    // sequence point: (line 96, col 9) to (line 96, col 67) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: call class [System.Collections]System.Collections.Generic.List`1<!!0> [System.Linq]System.Linq.Enumerable::ToList<int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>)
    IL_0010: pop
    // sequence point: (line 97, col 5) to (line 97, col 6) in _
    IL_0011: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateHashSet () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 63 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x21ba
    // Code size 18 (0x12)
    .maxstack 8

    // sequence point: (line 102, col 9) to (line 102, col 76) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: call class [System.Collections]System.Collections.Generic.HashSet`1<!!0> [System.Linq]System.Linq.Enumerable::ToHashSet<int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>)
    IL_0010: pop
    // sequence point: (line 103, col 5) to (line 103, col 6) in _
    IL_0011: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateImmutableHashSet () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 69 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x21cd
    // Code size 18 (0x12)
    .maxstack 8

    // sequence point: (line 108, col 9) to (line 108, col 94) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: call class [System.Collections.Immutable]System.Collections.Immutable.ImmutableHashSet`1<!!0> [System.Collections.Immutable]System.Collections.Immutable.ImmutableHashSet::ToImmutableHashSet<int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>)
    IL_0010: pop
    // sequence point: (line 109, col 5) to (line 109, col 6) in _
    IL_0011: ret
}
// .NET 8
.method public hidebysig 
    instance void CreateFrozenSet () cil managed 
{
    .custom instance void [BenchmarkDotNet.Annotations]BenchmarkDotNet.Attributes.BenchmarkAttribute::.ctor(int32, string) = (
        01 00 6f 00 00 00 01 5f 00 00
    )
    // Method begins at RVA 0x21e0
    // Code size 19 (0x13)
    .maxstack 8

    // sequence point: (line 114, col 9) to (line 114, col 82) in _
    IL_0000: ldc.i4.0
    IL_0001: ldc.i4 100000
    IL_0006: call class [System.Runtime]System.Collections.Generic.IEnumerable`1<int32> [System.Linq]System.Linq.Enumerable::Range(int32, int32)
    IL_000b: ldnull
    IL_000c: call class [System.Collections.Immutable]System.Collections.Frozen.FrozenSet`1<!!0> [System.Collections.Immutable]System.Collections.Frozen.FrozenSet::ToFrozenSet<int32>(class [System.Runtime]System.Collections.Generic.IEnumerable`1<!!0>, class [System.Runtime]System.Collections.Generic.IEqualityComparer`1<!!0>)
    IL_0011: pop
    // sequence point: (line 115, col 5) to (line 115, col 6) in _
    IL_0012: ret
}

// .NET 8 Jit Asm Code unavailable due to errors:
Type FrozenCollection+<>c has a static constructor, which is not supported by SharpLab JIT decompiler.


Benchmark Description:


Introduced in .𝗡𝗘𝗧 𝟴, 𝗙𝗿𝗼𝘇𝗲𝗻𝗗𝗶𝗰𝘁𝗶𝗼𝗻𝗮𝗿𝘆 and 𝗙𝗿𝗼𝘇𝗲𝗻𝗦𝗲𝘁 are new collection types designed for creating immutable 𝘿𝙞𝙘𝙩𝙞𝙤𝙣𝙖𝙧𝙞𝙚𝙨 and 𝙎𝙚𝙩𝙨. This immutability allows for optimizations that deliver excellent read performance, making them ideal for scenarios where you create the 𝙙𝙞𝙘𝙩𝙞𝙤𝙣𝙖𝙧𝙮 or 𝙨𝙚𝙩 once, and will not need to change keys or values, but will access data frequently at runtime. 𝗙𝗿𝗼𝘇𝗲𝗻𝗗𝗶𝗰𝘁𝗶𝗼𝗻𝗮𝗿𝘆 and 𝗙𝗿𝗼𝘇𝗲𝗻𝗦𝗲𝘁 have a relatively 𝙝𝙞𝙜𝙝 𝙘𝙤𝙨𝙩 to create but provide excellent lookup performance. They are ideal for cases where a 𝙙𝙞𝙘𝙩𝙞𝙤𝙣𝙖𝙧𝙮 or 𝙨𝙚𝙩 is created once, potentially at the startup of an application, and is used throughout the remainder of the life of the application.

The benchmark setup provided is designed to evaluate the performance of various collection types in .NET, specifically focusing on operations like `TryGetValue` and the creation of collections. The collections being benchmarked include standard mutable collections (`Dictionary<int, int>` and `HashSet<int>`), immutable collections (`ImmutableDictionary<int, int>` and `ImmutableHashSet<int>`), and hypothetical "frozen" collections (`FrozenDictionary<int, int>` and `FrozenSet<int>`). The benchmarks are run using BenchmarkDotNet, a powerful .NET library for benchmarking, with configurations to order the results from fastest to slowest, disable memory diagnosis, and use a specific ranking and markdown exporter for the results. ### General Setup - **.NET Version**: The .NET version isn't explicitly mentioned, but it's implied that a version supporting `System.Collections.Immutable` and the benchmarking library `BenchmarkDotNet` is used. This would typically mean .NET Core 3.1, .NET 5, or .NET 6, as these versions are widely used for performance benchmarking. - **Configuration**: The benchmarks are configured to disable memory diagnosis (which would track allocations), order the results from fastest to slowest, and export the results in markdown format with an Arabic numeral ranking system. ### Benchmark Methods Rationale and What They Measure #### `TryGetValue` Methods - **Purpose**: These methods measure the performance of retrieving a value by key from different types of collections. - **Importance**: `TryGetValue` is a common operation in many applications, and its performance can significantly affect overall application speed, especially in scenarios involving large datasets or frequent access patterns. - **Expected Insights**: These benchmarks will highlight the speed of lookups in mutable vs. immutable vs. frozen collections. Immutable and frozen collections typically have different performance characteristics due to their underlying data structures optimized for non-mutability. #### `Create` Methods - **Purpose**: These methods measure the time it takes to create and populate various types of collections with a fixed number of elements. - **Importance**: The creation time of a collection is crucial in scenarios where collections need to be frequently created and disposed of, affecting both performance and memory usage. - **Expected Insights**: These benchmarks will provide insights into the overhead associated with creating immutable and frozen collections compared to their mutable counterparts. Immutable and frozen collections might have higher creation costs due to the need to ensure immutability or thread-safety. ### Specific Performance Aspects - **Mutable vs. Immutable vs. Frozen**: Comparing these different types of collections helps understand the trade-offs between speed, memory usage, and thread-safety. Immutable and frozen collections are thread-safe by design, making them suitable for concurrent read operations without locks, but this might come at the cost of slower write operations and higher memory usage. - **Collection Creation**: Evaluating how quickly collections can be instantiated and populated is essential for understanding the initial setup cost in applications. This is particularly relevant for applications that dynamically generate large datasets. - **Lookup Performance**: The speed of `TryGetValue` operations is critical for many applications, especially those that perform many read operations on large datasets. This benchmark will help identify which collection types offer the best performance for read-heavy workloads. By running these benchmarks, developers can make informed decisions about which collection types to use in different parts of their applications, balancing the need for performance, memory efficiency, and thread-safety.


Benchmark Comments: