Skip to content

Benchmarks for #117427 (EgorBo) #428

@EgorBot

Description

@EgorBot

Processing dotnet/runtime#117427 (comment) command:

Command

-amd

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

public class StringDictionaryDefault
{
    private static readonly Dictionary<string, int> StringDictionary = new ()
    {
        { "DOTNET_ThreadPool_UnfairSemaphoreSpinLimit" + 1, 1 },
        { "Hello World" + 2, 2 },
        { "aa" + 3, 3 }
    };

    [Benchmark] public int LongKey() => StringDictionary["DOTNET_ThreadPool_UnfairSemaphoreSpinLimit1"];
    [Benchmark] public int MediumKey() => StringDictionary["Hello World2"];
    [Benchmark] public int ShortKey() => StringDictionary["aa3"];
}

public class StringDictionaryIgnoreCase
{
    private static readonly Dictionary<string, int> StringDictionary = new(StringComparer.OrdinalIgnoreCase)
    {
        { "DOTNET_ThreadPool_UnfairSemaphoreSpinLimit" + 1, 1 },
        { "Hello World" + 2, 2 },
        { "aa" + 3, 3 }
    };

    [Benchmark] public int LongKey_IgnoreCase() => StringDictionary["DOTNET_ThreadPool_UnfairSemaphoreSpinLimit1"];
    [Benchmark] public int MediumKey_IgnoreCase() => StringDictionary["Hello World2"];
    [Benchmark] public int ShortKey_IgnoreCase() => StringDictionary["aa3"];
}

</details>

(*EgorBot will reply in this issue*)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions