Skip to content

ImmutableList.Contains is few times slower that List.Contains or LinkedList.Contains #29086

@adamsitnik

Description

@adamsitnik

How to run the benchmarks:

git clone https://github.com/dotnet/performance.git
# if you have .NET Core 3.0 installed
dotnet run -c Release -f netcoreapp3.0 -p .\performance\src\benchmarks\micro\MicroBenchmarks.csproj --filter *ContainsFalse*List *ContainsTrue*List --join
# if you don't have .NET Core 3.0 installed
py .\performance\scripts\benchmarks_ci.py -f netcoreapp3.0 --filter *ContainsFalse*List *ContainsTrue*List --bdn-arguments="--join true"
Type Method Size Mean
ContainsFalse<Int32> List 512 133.49 us
ContainsFalse<String> List 512 874.65 us
ContainsTrue<Int32> List 512 71.70 us
ContainsTrue<String> List 512 482.38 us
ContainsFalse<Int32> LinkedList 512 440.38 us
ContainsFalse<String> LinkedList 512 1,377.87 us
ContainsTrue<Int32> LinkedList 512 224.22 us
ContainsTrue<String> LinkedList 512 672.24 us
ContainsFalse<Int32> ImmutableList 512 13,338.16 us
ContainsFalse<String> ImmutableList 512 24,118.15 us
ContainsTrue<Int32> ImmutableList 512 6,590.86 us
ContainsTrue<String> ImmutableList 512 12,033.68 us

Full docs for the new benchmarking workflow: https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-corefx.md

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions