├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ └── dotnet.yml ├── .gitignore ├── BenchmarkDotNet.Artifacts ├── results (final) │ ├── Benchmarks.ContainsBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_Int32_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_String_-report-github.md │ ├── Benchmarks.ContainsBenchmark_StructInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_StructStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_Int32_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_String_-report-github.md │ ├── Benchmarks.InitializeBenchmark_StructInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_StructStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_Int32_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_String_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_StructInts_-report-github.md │ └── Benchmarks.TryGetValueBenchmark_StructStrings_-report-github.md ├── results (v1-length-10K,1M-without-bigO) │ ├── Benchmarks.ContainsBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_Int32_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_String_-report-github.md │ ├── Benchmarks.ContainsBenchmark_StructInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_StructStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_Int32_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.InitializeBenchmark_String_-report-github.md │ ├── Benchmarks.InitializeBenchmark_StructInts_-report-github.md │ ├── Benchmarks.InitializeBenchmark_StructStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_Int32_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_String_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_StructInts_-report-github.md │ └── Benchmarks.TryGetValueBenchmark_StructStrings_-report-github.md └── results (v2-length-1K-with-bigO) │ ├── Benchmarks.ContainsBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_Int32_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.ContainsBenchmark_String_-report-github.md │ ├── Benchmarks.ContainsBenchmark_StructInts_-report-github.md │ ├── Benchmarks.ContainsBenchmark_StructStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_ClassInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_ClassStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_Int32_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordClassInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordClassStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordStructInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_RecordStructStrings_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_String_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_StructInts_-report-github.md │ ├── Benchmarks.TryGetValueBenchmark_StructStrings_-report-github.md │ └── rich-html-files.zip ├── Benchmarks ├── Base │ ├── BenchmarkBase.cs │ └── CustomConfig.cs ├── ContainsBenchmark.cs ├── InitializeBenchmark.cs └── TryGetValueBenchmark.cs ├── DataTypes ├── ClassInts.cs ├── ClassStrings.cs ├── RecordClassInts.cs ├── RecordClassStrings.cs ├── RecordStructInts.cs ├── RecordStructStrings.cs ├── StructInts.cs └── StructStrings.cs ├── DotNet-Collections-Benchmark.csproj ├── DotNet-Collections-Benchmark.sln ├── LICENSE ├── Program.cs ├── README.md ├── Tests └── OperationCounter.cs ├── Utils ├── ArrayExtensions.cs ├── CollectionExtensions.cs ├── ImmutableArrayExtensions.cs ├── ImmutableListExtensions.cs └── ListExtensions.cs └── docs ├── Benchmark-Initialize-Allocated-Preview.png ├── Benchmark-Initialize-Allocated.html ├── Benchmark-Initialize-Allocated.png ├── Benchmark-Initialize-Allocated.webp ├── Benchmark-Initialize-Mean-Preview.png ├── Benchmark-Initialize-Mean.html ├── Benchmark-Initialize-Mean.png ├── Benchmark-Initialize-Mean.webp ├── Benchmark-SearchContains-Allocated-Preview.png ├── Benchmark-SearchContains-Allocated.html ├── Benchmark-SearchContains-Allocated.png ├── Benchmark-SearchContains-Allocated.webp ├── Benchmark-SearchContains-Mean-Preview.png ├── Benchmark-SearchContains-Mean.html ├── Benchmark-SearchContains-Mean.png ├── Benchmark-SearchContains-Mean.webp ├── Benchmark-SearchTryGetValue-Allocated-Preview.png ├── Benchmark-SearchTryGetValue-Allocated.html ├── Benchmark-SearchTryGetValue-Allocated.png ├── Benchmark-SearchTryGetValue-Allocated.webp ├── Benchmark-SearchTryGetValue-Mean-Preview.png ├── Benchmark-SearchTryGetValue-Mean.html ├── Benchmark-SearchTryGetValue-Mean.png ├── Benchmark-SearchTryGetValue-Mean.webp ├── assets ├── bootstrap.min.css ├── cshtml-razor.min.js └── site.css ├── cshtml-razor.min.js ├── index.html └── repository-image.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "nuget" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a .NET project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net 3 | 4 | name: .NET 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v4.1.1 20 | 21 | - name: Setup .NET 22 | uses: actions/setup-dotnet@v4.0.0 23 | with: 24 | dotnet-version: 8.x.x 25 | 26 | - name: Restore dependencies 27 | run: dotnet restore 28 | 29 | - name: Build (Release) 30 | run: dotnet build --configuration Release --no-restore 31 | 32 | - name: Test (Release) 33 | run: dotnet test --configuration Release --no-build --no-restore 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.ContainsBenchmark_ClassInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |---------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **ClassInts** | **1000** | **False** | **3.816 ns** | **0.3439 ns** | **0.0188 ns** | **-** | 16 | | FrozenDictionary | O(1) | ClassInts | 1000 | False | 3.970 ns | 0.8071 ns | 0.0442 ns | - | 17 | | Dictionary | O(1) | ClassInts | 1000 | False | 5.605 ns | 0.5061 ns | 0.0277 ns | - | 18 | | HashSet | O(1) | ClassInts | 1000 | False | 5.896 ns | 0.8437 ns | 0.0462 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | False | 7.707 ns | 0.5068 ns | 0.0278 ns | - | 20 | | ImmutableDictionary | O(1) | ClassInts | 1000 | False | 10.967 ns | 0.5921 ns | 0.0325 ns | - | 21 | | ImmutableHashSet | O(1) | ClassInts | 1000 | False | 24.802 ns | 2.6348 ns | 0.1444 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **ClassInts** | **1000** | **True** | **7.293 ns** | **0.9093 ns** | **0.0498 ns** | **-** | 24 | | FrozenDictionary | O(1) | ClassInts | 1000 | True | 7.667 ns | 2.8821 ns | 0.1580 ns | - | 25 | | HashSet | O(1) | ClassInts | 1000 | True | 9.332 ns | 0.7328 ns | 0.0402 ns | - | 26 | | Dictionary | O(1) | ClassInts | 1000 | True | 10.268 ns | 1.6772 ns | 0.0919 ns | - | 27 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | True | 11.855 ns | 2.1780 ns | 0.1194 ns | - | 28 | | ImmutableDictionary | O(1) | ClassInts | 1000 | True | 17.843 ns | 4.8202 ns | 0.2642 ns | - | 29 | | ImmutableHashSet | O(1) | ClassInts | 1000 | True | 28.555 ns | 3.5986 ns | 0.1973 ns | - | 30 | | | | | | | | | | | 31 | | **'Array (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **False** | **36.756 ns** | **7.9028 ns** | **0.4332 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 37.883 ns | 12.6570 ns | 0.6938 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 39.942 ns | 1.4205 ns | 0.0779 ns | - | 34 | | SortedSet | O(log(N)) | ClassInts | 1000 | False | 40.534 ns | 11.2143 ns | 0.6147 ns | - | 35 | | SortedList | O(log(N)) | ClassInts | 1000 | False | 46.525 ns | 12.5093 ns | 0.6857 ns | - | 36 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | False | 50.695 ns | 1.1834 ns | 0.0649 ns | - | 37 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | False | 52.178 ns | 2.5300 ns | 0.1387 ns | - | 38 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | False | 63.056 ns | 10.0247 ns | 0.5495 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 77.122 ns | 19.9195 ns | 1.0919 ns | - | 40 | | | | | | | | | | | 41 | | **'Array (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **True** | **36.618 ns** | **2.7424 ns** | **0.1503 ns** | **-** | 42 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 37.077 ns | 11.5146 ns | 0.6312 ns | - | 43 | | SortedSet | O(log(N)) | ClassInts | 1000 | True | 37.702 ns | 8.5544 ns | 0.4689 ns | - | 44 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 39.211 ns | 1.6640 ns | 0.0912 ns | - | 45 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | True | 41.586 ns | 6.6197 ns | 0.3628 ns | - | 46 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | True | 42.858 ns | 3.6642 ns | 0.2008 ns | - | 47 | | SortedList | O(log(N)) | ClassInts | 1000 | True | 43.436 ns | 6.7912 ns | 0.3722 ns | - | 48 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | True | 58.380 ns | 2.8560 ns | 0.1565 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 64.249 ns | 3.4480 ns | 0.1890 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **False** | **773.154 ns** | **161.5290 ns** | **8.8539 ns** | **-** | 52 | | Array | O(N) | ClassInts | 1000 | False | 1,495.015 ns | 156.0190 ns | 8.5519 ns | - | 53 | | List | O(N) | ClassInts | 1000 | False | 1,734.703 ns | 135.2084 ns | 7.4112 ns | - | 54 | | ImmutableArray | O(N) | ClassInts | 1000 | False | 1,762.379 ns | 452.0526 ns | 24.7785 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **True** | **378.222 ns** | **92.7520 ns** | **5.0840 ns** | **-** | 57 | | Array | O(N) | ClassInts | 1000 | True | 722.915 ns | 62.4702 ns | 3.4242 ns | - | 58 | | List | O(N) | ClassInts | 1000 | True | 841.805 ns | 201.8899 ns | 11.0663 ns | - | 59 | | ImmutableArray | O(N) | ClassInts | 1000 | True | 850.812 ns | 122.4955 ns | 6.7144 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.ContainsBenchmark_ClassStrings_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |------------- |------- |-------- |------------:|-------------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **ClassStrings** | **1000** | **False** | **23.75 ns** | **2.486 ns** | **0.136 ns** | **-** | 16 | | FrozenDictionary | O(1) | ClassStrings | 1000 | False | 23.77 ns | 2.596 ns | 0.142 ns | - | 17 | | HashSet | O(1) | ClassStrings | 1000 | False | 25.09 ns | 3.944 ns | 0.216 ns | - | 18 | | Dictionary | O(1) | ClassStrings | 1000 | False | 26.48 ns | 2.090 ns | 0.115 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | False | 27.76 ns | 1.982 ns | 0.109 ns | - | 20 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | False | 30.32 ns | 2.906 ns | 0.159 ns | - | 21 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | False | 40.72 ns | 10.356 ns | 0.568 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **ClassStrings** | **1000** | **True** | **27.47 ns** | **1.917 ns** | **0.105 ns** | **-** | 24 | | FrozenDictionary | O(1) | ClassStrings | 1000 | True | 27.90 ns | 1.254 ns | 0.069 ns | - | 25 | | Dictionary | O(1) | ClassStrings | 1000 | True | 29.96 ns | 2.548 ns | 0.140 ns | - | 26 | | HashSet | O(1) | ClassStrings | 1000 | True | 30.39 ns | 3.248 ns | 0.178 ns | - | 27 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | True | 32.11 ns | 4.866 ns | 0.267 ns | - | 28 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | True | 34.77 ns | 2.034 ns | 0.111 ns | - | 29 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | True | 45.61 ns | 7.597 ns | 0.416 ns | - | 30 | | | | | | | | | | | 31 | | **'List (Sorted + BinarySearch)'** | **O(log(N))** | **ClassStrings** | **1000** | **False** | **318.19 ns** | **40.186 ns** | **2.203 ns** | **-** | 32 | | SortedSet | O(log(N)) | ClassStrings | 1000 | False | 318.67 ns | 34.975 ns | 1.917 ns | - | 33 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 320.15 ns | 20.158 ns | 1.105 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 326.21 ns | 57.223 ns | 3.137 ns | - | 35 | | SortedList | O(log(N)) | ClassStrings | 1000 | False | 327.96 ns | 21.865 ns | 1.199 ns | - | 36 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 332.48 ns | 108.409 ns | 5.942 ns | - | 37 | | ImmutableSortedSet | O(log(N)) | ClassStrings | 1000 | False | 333.72 ns | 22.293 ns | 1.222 ns | - | 38 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 364.69 ns | 68.964 ns | 3.780 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 366.50 ns | 47.879 ns | 2.624 ns | - | 40 | | | | | | | | | | | 41 | | **'ImmutableArray (Sorted + BinarySearch)'** | **O(log(N))** | **ClassStrings** | **1000** | **True** | **246.53 ns** | **19.237 ns** | **1.054 ns** | **-** | 42 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 247.97 ns | 40.149 ns | 2.201 ns | - | 43 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 252.79 ns | 63.682 ns | 3.491 ns | - | 44 | | ImmutableSortedSet | O(log(N)) | ClassStrings | 1000 | True | 253.33 ns | 65.397 ns | 3.585 ns | - | 45 | | SortedList | O(log(N)) | ClassStrings | 1000 | True | 259.50 ns | 16.546 ns | 0.907 ns | - | 46 | | SortedSet | O(log(N)) | ClassStrings | 1000 | True | 266.93 ns | 64.864 ns | 3.555 ns | - | 47 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 278.50 ns | 79.701 ns | 4.369 ns | - | 48 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 290.57 ns | 22.471 ns | 1.232 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 290.76 ns | 17.907 ns | 0.982 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **False** | **791.51 ns** | **141.688 ns** | **7.766 ns** | **-** | 52 | | ImmutableArray | O(N) | ClassStrings | 1000 | False | 3,974.60 ns | 342.106 ns | 18.752 ns | - | 53 | | List | O(N) | ClassStrings | 1000 | False | 4,067.15 ns | 1,557.257 ns | 85.359 ns | - | 54 | | Array | O(N) | ClassStrings | 1000 | False | 4,236.23 ns | 505.064 ns | 27.684 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **True** | **392.40 ns** | **62.709 ns** | **3.437 ns** | **-** | 57 | | ImmutableArray | O(N) | ClassStrings | 1000 | True | 1,914.95 ns | 127.458 ns | 6.986 ns | - | 58 | | Array | O(N) | ClassStrings | 1000 | True | 1,930.61 ns | 353.032 ns | 19.351 ns | - | 59 | | List | O(N) | ClassStrings | 1000 | True | 1,995.30 ns | 1,130.778 ns | 61.982 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.ContainsBenchmark_Int32_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |----------:|-----------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **Int32** | **1000** | **False** | **1.945 ns** | **0.0588 ns** | **0.0032 ns** | **-** | 16 | | FrozenDictionary | O(1) | Int32 | 1000 | False | 2.029 ns | 0.1983 ns | 0.0109 ns | - | 17 | | Dictionary | O(1) | Int32 | 1000 | False | 3.151 ns | 0.2901 ns | 0.0159 ns | - | 18 | | HashSet | O(1) | Int32 | 1000 | False | 3.557 ns | 0.2335 ns | 0.0128 ns | - | 19 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | False | 3.620 ns | 0.2061 ns | 0.0113 ns | - | 20 | | ImmutableDictionary | O(1) | Int32 | 1000 | False | 6.936 ns | 0.9263 ns | 0.0508 ns | - | 21 | | ImmutableHashSet | O(1) | Int32 | 1000 | False | 7.002 ns | 1.1803 ns | 0.0647 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **Int32** | **1000** | **True** | **2.105 ns** | **0.2321 ns** | **0.0127 ns** | **-** | 24 | | FrozenSet | O(1) | Int32 | 1000 | True | 2.348 ns | 0.6690 ns | 0.0367 ns | - | 25 | | HashSet | O(1) | Int32 | 1000 | True | 3.854 ns | 1.0097 ns | 0.0553 ns | - | 26 | | Dictionary | O(1) | Int32 | 1000 | True | 3.885 ns | 0.2723 ns | 0.0149 ns | - | 27 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | True | 4.289 ns | 0.4145 ns | 0.0227 ns | - | 28 | | ImmutableDictionary | O(1) | Int32 | 1000 | True | 6.075 ns | 2.0104 ns | 0.1102 ns | - | 29 | | ImmutableHashSet | O(1) | Int32 | 1000 | True | 6.100 ns | 2.0314 ns | 0.1113 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **False** | **12.098 ns** | **1.9697 ns** | **0.1080 ns** | **-** | 32 | | SortedList | O(log(N)) | Int32 | 1000 | False | 14.066 ns | 4.9435 ns | 0.2710 ns | - | 33 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.108 ns | 1.4230 ns | 0.0780 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.658 ns | 3.4903 ns | 0.1913 ns | - | 35 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 19.406 ns | 7.5607 ns | 0.4144 ns | - | 36 | | SortedDictionary | O(log(N)) | Int32 | 1000 | False | 23.119 ns | 3.2485 ns | 0.1781 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | False | 23.298 ns | 1.0291 ns | 0.0564 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | False | 23.324 ns | 2.6545 ns | 0.1455 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 28.372 ns | 6.6657 ns | 0.3654 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **True** | **11.001 ns** | **2.1815 ns** | **0.1196 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.082 ns | 2.2910 ns | 0.1256 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.183 ns | 1.5786 ns | 0.0865 ns | - | 44 | | SortedList | O(log(N)) | Int32 | 1000 | True | 14.344 ns | 0.4976 ns | 0.0273 ns | - | 45 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 14.669 ns | 1.7234 ns | 0.0945 ns | - | 46 | | SortedDictionary | O(log(N)) | Int32 | 1000 | True | 16.904 ns | 1.2891 ns | 0.0707 ns | - | 47 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | True | 18.442 ns | 1.7855 ns | 0.0979 ns | - | 48 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | True | 18.480 ns | 4.0187 ns | 0.2203 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 24.008 ns | 7.1657 ns | 0.3928 ns | - | 50 | | | | | | | | | | | 51 | | **List** | **O(N)** | **Int32** | **1000** | **False** | **43.877 ns** | **8.4752 ns** | **0.4646 ns** | **-** | 52 | | ReadOnlyCollection | O(N) | Int32 | 1000 | False | 44.524 ns | 4.7096 ns | 0.2581 ns | - | 53 | | ImmutableArray | O(N) | Int32 | 1000 | False | 68.765 ns | 10.3856 ns | 0.5693 ns | - | 54 | | Array | O(N) | Int32 | 1000 | False | 70.900 ns | 79.2658 ns | 4.3448 ns | - | 55 | | | | | | | | | | | 56 | | **List** | **O(N)** | **Int32** | **1000** | **True** | **29.495 ns** | **11.5223 ns** | **0.6316 ns** | **-** | 57 | | Array | O(N) | Int32 | 1000 | True | 30.105 ns | 3.9241 ns | 0.2151 ns | - | 58 | | ReadOnlyCollection | O(N) | Int32 | 1000 | True | 30.159 ns | 3.3028 ns | 0.1810 ns | - | 59 | | ImmutableArray | O(N) | Int32 | 1000 | True | 30.334 ns | 1.9629 ns | 0.1076 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.ContainsBenchmark_RecordStructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------------- |------- |-------- |-----------:|------------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **RecordStructInts** | **1000** | **False** | **2.595 ns** | **0.2810 ns** | **0.0154 ns** | **-** | 16 | | FrozenDictionary | O(1) | RecordStructInts | 1000 | False | 2.598 ns | 0.3018 ns | 0.0165 ns | - | 17 | | Dictionary | O(1) | RecordStructInts | 1000 | False | 4.380 ns | 0.2512 ns | 0.0138 ns | - | 18 | | HashSet | O(1) | RecordStructInts | 1000 | False | 4.425 ns | 0.1250 ns | 0.0069 ns | - | 19 | | ReadOnlyDictionary | O(1) | RecordStructInts | 1000 | False | 4.576 ns | 0.2102 ns | 0.0115 ns | - | 20 | | ImmutableDictionary | O(1) | RecordStructInts | 1000 | False | 7.573 ns | 1.0966 ns | 0.0601 ns | - | 21 | | ImmutableHashSet | O(1) | RecordStructInts | 1000 | False | 7.642 ns | 1.5060 ns | 0.0826 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **RecordStructInts** | **1000** | **True** | **3.618 ns** | **0.3391 ns** | **0.0186 ns** | **-** | 24 | | FrozenDictionary | O(1) | RecordStructInts | 1000 | True | 3.785 ns | 0.8025 ns | 0.0440 ns | - | 25 | | HashSet | O(1) | RecordStructInts | 1000 | True | 4.911 ns | 1.7936 ns | 0.0983 ns | - | 26 | | Dictionary | O(1) | RecordStructInts | 1000 | True | 4.986 ns | 0.1465 ns | 0.0080 ns | - | 27 | | ReadOnlyDictionary | O(1) | RecordStructInts | 1000 | True | 5.399 ns | 0.4077 ns | 0.0223 ns | - | 28 | | ImmutableHashSet | O(1) | RecordStructInts | 1000 | True | 7.693 ns | 2.5277 ns | 0.1386 ns | - | 29 | | ImmutableDictionary | O(1) | RecordStructInts | 1000 | True | 7.904 ns | 1.8532 ns | 0.1016 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **RecordStructInts** | **1000** | **False** | **13.978 ns** | **0.7222 ns** | **0.0396 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 18.674 ns | 1.9552 ns | 0.1072 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 18.848 ns | 1.2010 ns | 0.0658 ns | - | 34 | | 'List (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 19.021 ns | 2.6577 ns | 0.1457 ns | - | 35 | | SortedList | O(log(N)) | RecordStructInts | 1000 | False | 23.771 ns | 8.3139 ns | 0.4557 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | RecordStructInts | 1000 | False | 24.974 ns | 2.8214 ns | 0.1547 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 31.460 ns | 3.6933 ns | 0.2024 ns | - | 38 | | ImmutableSortedDictionary | O(log(N)) | RecordStructInts | 1000 | False | 36.904 ns | 6.3120 ns | 0.3460 ns | - | 39 | | ImmutableSortedSet | O(log(N)) | RecordStructInts | 1000 | False | 37.512 ns | 9.0715 ns | 0.4972 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **RecordStructInts** | **1000** | **True** | **17.640 ns** | **4.1919 ns** | **0.2298 ns** | **-** | 42 | | 'List (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.606 ns | 2.4490 ns | 0.1342 ns | - | 43 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.637 ns | 2.3828 ns | 0.1306 ns | - | 44 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.843 ns | 1.4851 ns | 0.0814 ns | - | 45 | | SortedList | O(log(N)) | RecordStructInts | 1000 | True | 26.691 ns | 8.7106 ns | 0.4775 ns | 32 B | 46 | | ImmutableSortedDictionary | O(log(N)) | RecordStructInts | 1000 | True | 27.080 ns | 7.2256 ns | 0.3961 ns | - | 47 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 27.141 ns | 3.5392 ns | 0.1940 ns | - | 48 | | SortedDictionary | O(log(N)) | RecordStructInts | 1000 | True | 27.407 ns | 7.4406 ns | 0.4078 ns | 32 B | 49 | | ImmutableSortedSet | O(log(N)) | RecordStructInts | 1000 | True | 29.574 ns | 3.2711 ns | 0.1793 ns | - | 50 | | | | | | | | | | | 51 | | **Array** | **O(N)** | **RecordStructInts** | **1000** | **False** | **484.841 ns** | **51.5342 ns** | **2.8248 ns** | **-** | 52 | | ImmutableArray | O(N) | RecordStructInts | 1000 | False | 493.708 ns | 63.8378 ns | 3.4992 ns | - | 53 | | List | O(N) | RecordStructInts | 1000 | False | 495.131 ns | 161.4268 ns | 8.8483 ns | - | 54 | | ReadOnlyCollection | O(N) | RecordStructInts | 1000 | False | 512.845 ns | 119.1040 ns | 6.5285 ns | - | 55 | | | | | | | | | | | 56 | | **List** | **O(N)** | **RecordStructInts** | **1000** | **True** | **252.419 ns** | **24.8989 ns** | **1.3648 ns** | **-** | 57 | | ReadOnlyCollection | O(N) | RecordStructInts | 1000 | True | 253.197 ns | 21.8176 ns | 1.1959 ns | - | 58 | | Array | O(N) | RecordStructInts | 1000 | True | 255.642 ns | 34.3234 ns | 1.8814 ns | - | 59 | | ImmutableArray | O(N) | RecordStructInts | 1000 | True | 257.205 ns | 12.2996 ns | 0.6742 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.ContainsBenchmark_String_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **String** | **1000** | **False** | **4.308 ns** | **0.0803 ns** | **0.0044 ns** | **-** | 16 | | FrozenDictionary | O(1) | String | 1000 | False | 4.405 ns | 0.4932 ns | 0.0270 ns | - | 17 | | HashSet | O(1) | String | 1000 | False | 6.841 ns | 1.0581 ns | 0.0580 ns | - | 18 | | Dictionary | O(1) | String | 1000 | False | 7.015 ns | 1.8951 ns | 0.1039 ns | - | 19 | | ReadOnlyDictionary | O(1) | String | 1000 | False | 8.961 ns | 2.6484 ns | 0.1452 ns | - | 20 | | ImmutableDictionary | O(1) | String | 1000 | False | 16.405 ns | 2.8413 ns | 0.1557 ns | - | 21 | | ImmutableHashSet | O(1) | String | 1000 | False | 26.570 ns | 3.4740 ns | 0.1904 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **String** | **1000** | **True** | **4.452 ns** | **0.1191 ns** | **0.0065 ns** | **-** | 24 | | FrozenDictionary | O(1) | String | 1000 | True | 4.987 ns | 0.4987 ns | 0.0273 ns | - | 25 | | HashSet | O(1) | String | 1000 | True | 8.720 ns | 0.2512 ns | 0.0138 ns | - | 26 | | Dictionary | O(1) | String | 1000 | True | 8.825 ns | 1.4643 ns | 0.0803 ns | - | 27 | | ReadOnlyDictionary | O(1) | String | 1000 | True | 11.300 ns | 2.2122 ns | 0.1213 ns | - | 28 | | ImmutableDictionary | O(1) | String | 1000 | True | 21.104 ns | 2.9163 ns | 0.1599 ns | - | 29 | | ImmutableHashSet | O(1) | String | 1000 | True | 28.374 ns | 1.4515 ns | 0.0796 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **String** | **1000** | **False** | **307.629 ns** | **40.8524 ns** | **2.2393 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 312.884 ns | 14.2113 ns | 0.7790 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 313.269 ns | 57.7894 ns | 3.1676 ns | - | 34 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 314.854 ns | 105.9571 ns | 5.8079 ns | - | 35 | | SortedList | O(log(N)) | String | 1000 | False | 322.710 ns | 107.3378 ns | 5.8835 ns | - | 36 | | ImmutableSortedSet | O(log(N)) | String | 1000 | False | 323.908 ns | 61.6276 ns | 3.3780 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | String | 1000 | False | 330.652 ns | 116.2749 ns | 6.3734 ns | - | 38 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 356.776 ns | 58.3859 ns | 3.2003 ns | - | 39 | | SortedDictionary | O(log(N)) | String | 1000 | False | 361.296 ns | 118.4797 ns | 6.4943 ns | - | 40 | | | | | | | | | | | 41 | | **ImmutableSortedDictionary** | **O(log(N))** | **String** | **1000** | **True** | **241.350 ns** | **79.5247 ns** | **4.3590 ns** | **-** | 42 | | ImmutableSortedSet | O(log(N)) | String | 1000 | True | 248.392 ns | 79.2214 ns | 4.3424 ns | - | 43 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 264.561 ns | 56.0615 ns | 3.0729 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 266.752 ns | 27.9816 ns | 1.5338 ns | - | 45 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 267.570 ns | 31.6018 ns | 1.7322 ns | - | 46 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 268.204 ns | 102.9788 ns | 5.6446 ns | - | 47 | | SortedList | O(log(N)) | String | 1000 | True | 271.979 ns | 22.9028 ns | 1.2554 ns | - | 48 | | SortedSet | O(log(N)) | String | 1000 | True | 272.019 ns | 76.0691 ns | 4.1696 ns | - | 49 | | SortedDictionary | O(log(N)) | String | 1000 | True | 280.641 ns | 10.9002 ns | 0.5975 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **False** | **2,851.432 ns** | **683.4577 ns** | **37.4626 ns** | **-** | 52 | | List | O(N) | String | 1000 | False | 3,747.693 ns | 485.0937 ns | 26.5896 ns | - | 53 | | ImmutableArray | O(N) | String | 1000 | False | 4,042.309 ns | 569.2436 ns | 31.2022 ns | - | 54 | | Array | O(N) | String | 1000 | False | 4,171.897 ns | 475.1176 ns | 26.0428 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **True** | **1,392.430 ns** | **60.8564 ns** | **3.3357 ns** | **-** | 57 | | List | O(N) | String | 1000 | True | 1,836.948 ns | 69.8249 ns | 3.8273 ns | - | 58 | | Array | O(N) | String | 1000 | True | 1,838.527 ns | 646.2116 ns | 35.4210 ns | - | 59 | | ImmutableArray | O(N) | String | 1000 | True | 1,869.762 ns | 776.7829 ns | 42.5781 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.ContainsBenchmark_StructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------- |------- |-------- |-------------:|--------------:|-------------:|----------:| 15 | | **FrozenSet** | **O(1)** | **StructInts** | **1000** | **False** | **20.32 ns** | **5.697 ns** | **0.312 ns** | **32 B** | 16 | | FrozenDictionary | O(1) | StructInts | 1000 | False | 20.49 ns | 3.656 ns | 0.200 ns | 32 B | 17 | | HashSet | O(1) | StructInts | 1000 | False | 22.29 ns | 7.726 ns | 0.423 ns | 32 B | 18 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | False | 22.84 ns | 0.328 ns | 0.018 ns | 32 B | 19 | | Dictionary | O(1) | StructInts | 1000 | False | 24.19 ns | 2.166 ns | 0.119 ns | 32 B | 20 | | ImmutableDictionary | O(1) | StructInts | 1000 | False | 25.33 ns | 3.162 ns | 0.173 ns | 32 B | 21 | | ImmutableHashSet | O(1) | StructInts | 1000 | False | 27.69 ns | 8.744 ns | 0.479 ns | 32 B | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **StructInts** | **1000** | **True** | **35.92 ns** | **24.385 ns** | **1.337 ns** | **96 B** | 24 | | FrozenDictionary | O(1) | StructInts | 1000 | True | 36.45 ns | 21.510 ns | 1.179 ns | 96 B | 25 | | HashSet | O(1) | StructInts | 1000 | True | 39.24 ns | 29.821 ns | 1.635 ns | 96 B | 26 | | ImmutableDictionary | O(1) | StructInts | 1000 | True | 40.29 ns | 22.601 ns | 1.239 ns | 96 B | 27 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | True | 40.91 ns | 13.843 ns | 0.759 ns | 96 B | 28 | | ImmutableHashSet | O(1) | StructInts | 1000 | True | 41.37 ns | 25.692 ns | 1.408 ns | 96 B | 29 | | Dictionary | O(1) | StructInts | 1000 | True | 41.99 ns | 19.671 ns | 1.078 ns | 96 B | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **False** | **12.96 ns** | **7.283 ns** | **0.399 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 18.93 ns | 2.100 ns | 0.115 ns | - | 33 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.17 ns | 2.258 ns | 0.124 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.19 ns | 1.790 ns | 0.098 ns | - | 35 | | SortedList | O(log(N)) | StructInts | 1000 | False | 23.86 ns | 6.965 ns | 0.382 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | StructInts | 1000 | False | 24.52 ns | 6.728 ns | 0.369 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 31.48 ns | 7.400 ns | 0.406 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | False | 37.11 ns | 5.834 ns | 0.320 ns | - | 39 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | False | 37.15 ns | 5.070 ns | 0.278 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **True** | **17.81 ns** | **3.540 ns** | **0.194 ns** | **-** | 42 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.24 ns | 4.076 ns | 0.223 ns | - | 43 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.27 ns | 0.536 ns | 0.029 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.60 ns | 4.917 ns | 0.270 ns | - | 45 | | SortedDictionary | O(log(N)) | StructInts | 1000 | True | 24.90 ns | 1.297 ns | 0.071 ns | 32 B | 46 | | SortedList | O(log(N)) | StructInts | 1000 | True | 25.58 ns | 3.680 ns | 0.202 ns | 32 B | 47 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 27.15 ns | 2.459 ns | 0.135 ns | - | 48 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | True | 29.41 ns | 1.524 ns | 0.084 ns | - | 49 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | True | 29.56 ns | 6.592 ns | 0.361 ns | - | 50 | | | | | | | | | | | 51 | | **Array** | **O(N)** | **StructInts** | **1000** | **False** | **12,463.03 ns** | **11,691.582 ns** | **640.855 ns** | **64000 B** | 52 | | List | O(N) | StructInts | 1000 | False | 13,190.33 ns | 9,086.595 ns | 498.067 ns | 64000 B | 53 | | ImmutableArray | O(N) | StructInts | 1000 | False | 13,202.27 ns | 20,087.818 ns | 1,101.081 ns | 64000 B | 54 | | ReadOnlyCollection | O(N) | StructInts | 1000 | False | 13,302.69 ns | 15,827.541 ns | 867.561 ns | 64000 B | 55 | | | | | | | | | | | 56 | | **Array** | **O(N)** | **StructInts** | **1000** | **True** | **6,322.55 ns** | **5,531.420 ns** | **303.196 ns** | **30901 B** | 57 | | ImmutableArray | O(N) | StructInts | 1000 | True | 6,373.33 ns | 5,837.792 ns | 319.989 ns | 30901 B | 58 | | List | O(N) | StructInts | 1000 | True | 6,377.23 ns | 4,884.856 ns | 267.755 ns | 30901 B | 59 | | ReadOnlyCollection | O(N) | StructInts | 1000 | True | 6,487.09 ns | 7,103.222 ns | 389.352 ns | 30901 B | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.TryGetValueBenchmark_ClassInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |---------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **ClassInts** | **1000** | **False** | **3.893 ns** | **0.1170 ns** | **0.0064 ns** | **-** | 16 | | Dictionary | O(1) | ClassInts | 1000 | False | 5.800 ns | 0.6555 ns | 0.0359 ns | - | 17 | | HashSet | O(1) | ClassInts | 1000 | False | 6.058 ns | 0.5716 ns | 0.0313 ns | - | 18 | | FrozenSet | O(1) | ClassInts | 1000 | False | 7.170 ns | 0.7202 ns | 0.0395 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | False | 8.227 ns | 0.4546 ns | 0.0249 ns | - | 20 | | ImmutableHashSet | O(1) | ClassInts | 1000 | False | 10.564 ns | 2.0148 ns | 0.1104 ns | - | 21 | | ImmutableDictionary | O(1) | ClassInts | 1000 | False | 11.503 ns | 2.1492 ns | 0.1178 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **ClassInts** | **1000** | **True** | **7.734 ns** | **1.7179 ns** | **0.0942 ns** | **-** | 24 | | Dictionary | O(1) | ClassInts | 1000 | True | 9.370 ns | 1.2367 ns | 0.0678 ns | - | 25 | | HashSet | O(1) | ClassInts | 1000 | True | 9.552 ns | 1.4827 ns | 0.0813 ns | - | 26 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | True | 12.288 ns | 2.8657 ns | 0.1571 ns | - | 27 | | FrozenSet | O(1) | ClassInts | 1000 | True | 13.617 ns | 1.1161 ns | 0.0612 ns | - | 28 | | ImmutableHashSet | O(1) | ClassInts | 1000 | True | 15.310 ns | 5.3803 ns | 0.2949 ns | - | 29 | | ImmutableDictionary | O(1) | ClassInts | 1000 | True | 17.573 ns | 0.7587 ns | 0.0416 ns | - | 30 | | | | | | | | | | | 31 | | **'List (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **False** | **36.647 ns** | **9.3205 ns** | **0.5109 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 37.925 ns | 5.4951 ns | 0.3012 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 39.116 ns | 16.9538 ns | 0.9293 ns | - | 34 | | SortedSet | O(log(N)) | ClassInts | 1000 | False | 42.620 ns | 8.3177 ns | 0.4559 ns | - | 35 | | SortedList | O(log(N)) | ClassInts | 1000 | False | 48.149 ns | 42.0762 ns | 2.3063 ns | - | 36 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | False | 48.278 ns | 11.8497 ns | 0.6495 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | False | 52.262 ns | 4.9041 ns | 0.2688 ns | - | 38 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | False | 60.603 ns | 4.7155 ns | 0.2585 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 79.511 ns | 20.5448 ns | 1.1261 ns | - | 40 | | | | | | | | | | | 41 | | **'List (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **True** | **36.386 ns** | **5.4246 ns** | **0.2973 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 38.523 ns | 1.1629 ns | 0.0637 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 39.157 ns | 7.1774 ns | 0.3934 ns | - | 44 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | True | 39.679 ns | 2.4508 ns | 0.1343 ns | - | 45 | | SortedSet | O(log(N)) | ClassInts | 1000 | True | 39.951 ns | 15.2387 ns | 0.8353 ns | - | 46 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | True | 42.528 ns | 4.8931 ns | 0.2682 ns | - | 47 | | SortedList | O(log(N)) | ClassInts | 1000 | True | 43.552 ns | 5.2954 ns | 0.2903 ns | - | 48 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | True | 59.154 ns | 9.6093 ns | 0.5267 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 68.583 ns | 4.8163 ns | 0.2640 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **False** | **773.975 ns** | **105.2108 ns** | **5.7670 ns** | **-** | 52 | | ImmutableArray | O(N) | ClassInts | 1000 | False | 1,504.838 ns | 258.8998 ns | 14.1912 ns | - | 53 | | List | O(N) | ClassInts | 1000 | False | 1,508.505 ns | 109.9052 ns | 6.0243 ns | - | 54 | | Array | O(N) | ClassInts | 1000 | False | 1,736.114 ns | 224.0401 ns | 12.2804 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **True** | **265.686 ns** | **38.7472 ns** | **2.1239 ns** | **-** | 57 | | List | O(N) | ClassInts | 1000 | True | 726.899 ns | 89.2420 ns | 4.8917 ns | - | 58 | | Array | O(N) | ClassInts | 1000 | True | 841.566 ns | 78.2787 ns | 4.2907 ns | - | 59 | | ImmutableArray | O(N) | ClassInts | 1000 | True | 852.207 ns | 251.4988 ns | 13.7855 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.TryGetValueBenchmark_ClassStrings_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |------------- |------- |-------- |------------:|-------------:|----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **ClassStrings** | **1000** | **False** | **23.98 ns** | **0.452 ns** | **0.025 ns** | **-** | 16 | | FrozenSet | O(1) | ClassStrings | 1000 | False | 26.46 ns | 0.456 ns | 0.025 ns | - | 17 | | HashSet | O(1) | ClassStrings | 1000 | False | 26.76 ns | 0.408 ns | 0.022 ns | - | 18 | | Dictionary | O(1) | ClassStrings | 1000 | False | 26.80 ns | 1.645 ns | 0.090 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | False | 27.73 ns | 2.351 ns | 0.129 ns | - | 20 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | False | 30.47 ns | 2.660 ns | 0.146 ns | - | 21 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | False | 30.72 ns | 0.623 ns | 0.034 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **ClassStrings** | **1000** | **True** | **27.86 ns** | **4.357 ns** | **0.239 ns** | **-** | 24 | | Dictionary | O(1) | ClassStrings | 1000 | True | 30.29 ns | 6.321 ns | 0.346 ns | - | 25 | | HashSet | O(1) | ClassStrings | 1000 | True | 30.82 ns | 5.325 ns | 0.292 ns | - | 26 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | True | 33.20 ns | 8.883 ns | 0.487 ns | - | 27 | | FrozenSet | O(1) | ClassStrings | 1000 | True | 33.70 ns | 5.565 ns | 0.305 ns | - | 28 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | True | 34.40 ns | 2.157 ns | 0.118 ns | - | 29 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | True | 35.85 ns | 4.065 ns | 0.223 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **ClassStrings** | **1000** | **False** | **321.25 ns** | **66.400 ns** | **3.640 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 323.10 ns | 96.490 ns | 5.289 ns | - | 33 | | SortedList | O(log(N)) | ClassStrings | 1000 | False | 335.78 ns | 106.597 ns | 5.843 ns | - | 34 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 336.69 ns | 38.143 ns | 2.091 ns | - | 35 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 337.24 ns | 81.554 ns | 4.470 ns | - | 36 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 338.19 ns | 37.666 ns | 2.065 ns | - | 37 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 362.20 ns | 9.752 ns | 0.535 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | ClassStrings | 1000 | False | 362.93 ns | 12.923 ns | 0.708 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 380.81 ns | 42.232 ns | 2.315 ns | - | 40 | | | | | | | | | | | 41 | | **ImmutableSortedSet** | **O(log(N))** | **ClassStrings** | **1000** | **True** | **259.80 ns** | **19.087 ns** | **1.046 ns** | **-** | 42 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 260.24 ns | 32.740 ns | 1.795 ns | - | 43 | | SortedList | O(log(N)) | ClassStrings | 1000 | True | 266.62 ns | 35.902 ns | 1.968 ns | - | 44 | | SortedSet | O(log(N)) | ClassStrings | 1000 | True | 271.12 ns | 31.895 ns | 1.748 ns | - | 45 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 279.69 ns | 37.823 ns | 2.073 ns | - | 46 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 284.16 ns | 61.323 ns | 3.361 ns | - | 47 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 287.29 ns | 22.202 ns | 1.217 ns | - | 48 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 289.97 ns | 49.846 ns | 2.732 ns | - | 49 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 323.84 ns | 54.871 ns | 3.008 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **False** | **806.45 ns** | **25.769 ns** | **1.412 ns** | **-** | 52 | | ImmutableArray | O(N) | ClassStrings | 1000 | False | 4,104.14 ns | 561.662 ns | 30.787 ns | - | 53 | | Array | O(N) | ClassStrings | 1000 | False | 4,278.42 ns | 1,175.071 ns | 64.410 ns | - | 54 | | List | O(N) | ClassStrings | 1000 | False | 4,405.76 ns | 631.143 ns | 34.595 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **True** | **326.04 ns** | **53.764 ns** | **2.947 ns** | **-** | 57 | | List | O(N) | ClassStrings | 1000 | True | 1,956.09 ns | 813.244 ns | 44.577 ns | - | 58 | | ImmutableArray | O(N) | ClassStrings | 1000 | True | 1,983.68 ns | 248.286 ns | 13.609 ns | - | 59 | | Array | O(N) | ClassStrings | 1000 | True | 2,075.47 ns | 640.796 ns | 35.124 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.TryGetValueBenchmark_Int32_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |----------:|----------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **Int32** | **1000** | **False** | **2.017 ns** | **0.1896 ns** | **0.0104 ns** | **-** | 16 | | FrozenDictionary | O(1) | Int32 | 1000 | False | 2.030 ns | 0.1221 ns | 0.0067 ns | - | 17 | | Dictionary | O(1) | Int32 | 1000 | False | 3.391 ns | 0.5301 ns | 0.0291 ns | - | 18 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | False | 3.455 ns | 0.6222 ns | 0.0341 ns | - | 19 | | HashSet | O(1) | Int32 | 1000 | False | 3.481 ns | 0.5842 ns | 0.0320 ns | - | 20 | | ImmutableDictionary | O(1) | Int32 | 1000 | False | 7.248 ns | 3.0504 ns | 0.1672 ns | - | 21 | | ImmutableHashSet | O(1) | Int32 | 1000 | False | 7.340 ns | 2.7137 ns | 0.1487 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **Int32** | **1000** | **True** | **2.095 ns** | **0.2315 ns** | **0.0127 ns** | **-** | 24 | | FrozenSet | O(1) | Int32 | 1000 | True | 2.394 ns | 0.5573 ns | 0.0305 ns | - | 25 | | HashSet | O(1) | Int32 | 1000 | True | 2.853 ns | 0.5433 ns | 0.0298 ns | - | 26 | | Dictionary | O(1) | Int32 | 1000 | True | 4.085 ns | 0.1796 ns | 0.0098 ns | - | 27 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | True | 4.432 ns | 0.6207 ns | 0.0340 ns | - | 28 | | ImmutableDictionary | O(1) | Int32 | 1000 | True | 6.307 ns | 2.3095 ns | 0.1266 ns | - | 29 | | ImmutableHashSet | O(1) | Int32 | 1000 | True | 6.315 ns | 0.9480 ns | 0.0520 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **False** | **11.367 ns** | **2.2254 ns** | **0.1220 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 14.998 ns | 2.6544 ns | 0.1455 ns | - | 33 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.383 ns | 2.5442 ns | 0.1395 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.764 ns | 0.6891 ns | 0.0378 ns | - | 35 | | SortedList | O(log(N)) | Int32 | 1000 | False | 16.714 ns | 1.9644 ns | 0.1077 ns | - | 36 | | SortedDictionary | O(log(N)) | Int32 | 1000 | False | 19.917 ns | 1.2177 ns | 0.0667 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | False | 23.368 ns | 5.7702 ns | 0.3163 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | False | 24.754 ns | 3.4614 ns | 0.1897 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 28.555 ns | 0.5529 ns | 0.0303 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **True** | **12.824 ns** | **1.0387 ns** | **0.0569 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.101 ns | 1.0020 ns | 0.0549 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.181 ns | 1.1741 ns | 0.0644 ns | - | 44 | | SortedList | O(log(N)) | Int32 | 1000 | True | 13.182 ns | 1.1688 ns | 0.0641 ns | - | 45 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.594 ns | 3.7703 ns | 0.2067 ns | - | 46 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | True | 18.594 ns | 0.5907 ns | 0.0324 ns | - | 47 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | True | 18.637 ns | 0.7645 ns | 0.0419 ns | - | 48 | | SortedDictionary | O(log(N)) | Int32 | 1000 | True | 19.448 ns | 3.0688 ns | 0.1682 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 27.142 ns | 3.5470 ns | 0.1944 ns | - | 50 | | | | | | | | | | | 51 | | **Array** | **O(N)** | **Int32** | **1000** | **False** | **41.027 ns** | **7.8113 ns** | **0.4282 ns** | **-** | 52 | | ReadOnlyCollection | O(N) | Int32 | 1000 | False | 42.841 ns | 2.3381 ns | 0.1282 ns | - | 53 | | List | O(N) | Int32 | 1000 | False | 42.976 ns | 8.8244 ns | 0.4837 ns | - | 54 | | ImmutableArray | O(N) | Int32 | 1000 | False | 68.369 ns | 6.3947 ns | 0.3505 ns | - | 55 | | | | | | | | | | | 56 | | **Array** | **O(N)** | **Int32** | **1000** | **True** | **28.672 ns** | **3.1231 ns** | **0.1712 ns** | **-** | 57 | | List | O(N) | Int32 | 1000 | True | 29.101 ns | 8.8553 ns | 0.4854 ns | - | 58 | | ImmutableArray | O(N) | Int32 | 1000 | True | 30.060 ns | 1.7139 ns | 0.0939 ns | - | 59 | | ReadOnlyCollection | O(N) | Int32 | 1000 | True | 32.001 ns | 3.3766 ns | 0.1851 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.TryGetValueBenchmark_RecordStructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------------- |------- |-------- |-----------:|------------:|-----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **RecordStructInts** | **1000** | **False** | **2.496 ns** | **0.1072 ns** | **0.0059 ns** | **-** | 16 | | Dictionary | O(1) | RecordStructInts | 1000 | False | 2.594 ns | 0.4020 ns | 0.0220 ns | - | 17 | | FrozenSet | O(1) | RecordStructInts | 1000 | False | 2.770 ns | 0.4245 ns | 0.0233 ns | - | 18 | | HashSet | O(1) | RecordStructInts | 1000 | False | 4.426 ns | 0.5854 ns | 0.0321 ns | - | 19 | | ReadOnlyDictionary | O(1) | RecordStructInts | 1000 | False | 4.541 ns | 0.7166 ns | 0.0393 ns | - | 20 | | ImmutableDictionary | O(1) | RecordStructInts | 1000 | False | 7.737 ns | 1.1004 ns | 0.0603 ns | - | 21 | | ImmutableHashSet | O(1) | RecordStructInts | 1000 | False | 7.797 ns | 4.0188 ns | 0.2203 ns | - | 22 | | | | | | | | | | | 23 | | **Dictionary** | **O(1)** | **RecordStructInts** | **1000** | **True** | **3.575 ns** | **0.8067 ns** | **0.0442 ns** | **-** | 24 | | FrozenDictionary | O(1) | RecordStructInts | 1000 | True | 3.898 ns | 0.3738 ns | 0.0205 ns | - | 25 | | HashSet | O(1) | RecordStructInts | 1000 | True | 3.997 ns | 0.4230 ns | 0.0232 ns | - | 26 | | FrozenSet | O(1) | RecordStructInts | 1000 | True | 4.049 ns | 0.3128 ns | 0.0171 ns | - | 27 | | ReadOnlyDictionary | O(1) | RecordStructInts | 1000 | True | 5.672 ns | 1.2425 ns | 0.0681 ns | - | 28 | | ImmutableHashSet | O(1) | RecordStructInts | 1000 | True | 7.407 ns | 1.6315 ns | 0.0894 ns | - | 29 | | ImmutableDictionary | O(1) | RecordStructInts | 1000 | True | 7.762 ns | 1.5811 ns | 0.0867 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **RecordStructInts** | **1000** | **False** | **12.721 ns** | **0.4313 ns** | **0.0236 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 18.860 ns | 1.0939 ns | 0.0600 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 19.021 ns | 1.9994 ns | 0.1096 ns | - | 34 | | 'List (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 19.119 ns | 1.4449 ns | 0.0792 ns | - | 35 | | SortedList | O(log(N)) | RecordStructInts | 1000 | False | 23.539 ns | 2.1015 ns | 0.1152 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | RecordStructInts | 1000 | False | 24.387 ns | 6.5638 ns | 0.3598 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 32.269 ns | 3.5497 ns | 0.1946 ns | - | 38 | | ImmutableSortedDictionary | O(log(N)) | RecordStructInts | 1000 | False | 36.601 ns | 1.5659 ns | 0.0858 ns | - | 39 | | ImmutableSortedSet | O(log(N)) | RecordStructInts | 1000 | False | 37.911 ns | 8.9316 ns | 0.4896 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **RecordStructInts** | **1000** | **True** | **18.607 ns** | **3.8048 ns** | **0.2086 ns** | **-** | 42 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.193 ns | 1.8159 ns | 0.0995 ns | - | 43 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.234 ns | 1.1731 ns | 0.0643 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.436 ns | 3.1606 ns | 0.1732 ns | - | 45 | | SortedDictionary | O(log(N)) | RecordStructInts | 1000 | True | 25.049 ns | 3.9722 ns | 0.2177 ns | 32 B | 46 | | SortedList | O(log(N)) | RecordStructInts | 1000 | True | 26.215 ns | 8.8085 ns | 0.4828 ns | 32 B | 47 | | ImmutableSortedDictionary | O(log(N)) | RecordStructInts | 1000 | True | 28.917 ns | 0.9038 ns | 0.0495 ns | - | 48 | | ImmutableSortedSet | O(log(N)) | RecordStructInts | 1000 | True | 30.016 ns | 7.7888 ns | 0.4269 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 31.714 ns | 5.4908 ns | 0.3010 ns | - | 50 | | | | | | | | | | | 51 | | **List** | **O(N)** | **RecordStructInts** | **1000** | **False** | **491.131 ns** | **138.1953 ns** | **7.5750 ns** | **-** | 52 | | Array | O(N) | RecordStructInts | 1000 | False | 502.378 ns | 74.4153 ns | 4.0790 ns | - | 53 | | ImmutableArray | O(N) | RecordStructInts | 1000 | False | 505.744 ns | 95.9188 ns | 5.2576 ns | - | 54 | | ReadOnlyCollection | O(N) | RecordStructInts | 1000 | False | 513.425 ns | 296.4680 ns | 16.2504 ns | - | 55 | | | | | | | | | | | 56 | | **ImmutableArray** | **O(N)** | **RecordStructInts** | **1000** | **True** | **252.977 ns** | **30.7549 ns** | **1.6858 ns** | **-** | 57 | | List | O(N) | RecordStructInts | 1000 | True | 253.244 ns | 28.3128 ns | 1.5519 ns | - | 58 | | Array | O(N) | RecordStructInts | 1000 | True | 253.309 ns | 54.1572 ns | 2.9685 ns | - | 59 | | ReadOnlyCollection | O(N) | RecordStructInts | 1000 | True | 254.999 ns | 33.5267 ns | 1.8377 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.TryGetValueBenchmark_String_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **String** | **1000** | **False** | **4.421 ns** | **0.5035 ns** | **0.0276 ns** | **-** | 16 | | FrozenSet | O(1) | String | 1000 | False | 6.279 ns | 0.4430 ns | 0.0243 ns | - | 17 | | Dictionary | O(1) | String | 1000 | False | 7.095 ns | 1.3972 ns | 0.0766 ns | - | 18 | | HashSet | O(1) | String | 1000 | False | 7.151 ns | 1.3768 ns | 0.0755 ns | - | 19 | | ReadOnlyDictionary | O(1) | String | 1000 | False | 9.358 ns | 1.8240 ns | 0.1000 ns | - | 20 | | ImmutableHashSet | O(1) | String | 1000 | False | 15.515 ns | 3.4441 ns | 0.1888 ns | - | 21 | | ImmutableDictionary | O(1) | String | 1000 | False | 16.466 ns | 8.5353 ns | 0.4678 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **String** | **1000** | **True** | **4.857 ns** | **0.6566 ns** | **0.0360 ns** | **-** | 24 | | Dictionary | O(1) | String | 1000 | True | 8.973 ns | 1.2395 ns | 0.0679 ns | - | 25 | | HashSet | O(1) | String | 1000 | True | 9.021 ns | 0.4231 ns | 0.0232 ns | - | 26 | | FrozenSet | O(1) | String | 1000 | True | 10.957 ns | 1.4986 ns | 0.0821 ns | - | 27 | | ReadOnlyDictionary | O(1) | String | 1000 | True | 11.229 ns | 1.0306 ns | 0.0565 ns | - | 28 | | ImmutableHashSet | O(1) | String | 1000 | True | 19.697 ns | 2.6280 ns | 0.1441 ns | - | 29 | | ImmutableDictionary | O(1) | String | 1000 | True | 20.911 ns | 5.6117 ns | 0.3076 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **String** | **1000** | **False** | **303.085 ns** | **43.5154 ns** | **2.3852 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 311.216 ns | 25.6718 ns | 1.4072 ns | - | 33 | | SortedList | O(log(N)) | String | 1000 | False | 319.730 ns | 13.0537 ns | 0.7155 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 321.109 ns | 146.2676 ns | 8.0174 ns | - | 35 | | ImmutableSortedDictionary | O(log(N)) | String | 1000 | False | 323.934 ns | 91.7163 ns | 5.0273 ns | - | 36 | | ImmutableSortedSet | O(log(N)) | String | 1000 | False | 336.183 ns | 32.8334 ns | 1.7997 ns | - | 37 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 353.234 ns | 88.7693 ns | 4.8657 ns | - | 38 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 357.601 ns | 75.3227 ns | 4.1287 ns | - | 39 | | SortedDictionary | O(log(N)) | String | 1000 | False | 358.193 ns | 15.9219 ns | 0.8727 ns | - | 40 | | | | | | | | | | | 41 | | **ImmutableSortedDictionary** | **O(log(N))** | **String** | **1000** | **True** | **237.537 ns** | **45.9291 ns** | **2.5175 ns** | **-** | 42 | | ImmutableSortedSet | O(log(N)) | String | 1000 | True | 245.379 ns | 55.6813 ns | 3.0521 ns | - | 43 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 264.359 ns | 52.4840 ns | 2.8768 ns | - | 44 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 264.543 ns | 23.6696 ns | 1.2974 ns | - | 45 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 265.289 ns | 36.0121 ns | 1.9739 ns | - | 46 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 268.966 ns | 10.2658 ns | 0.5627 ns | - | 47 | | SortedList | O(log(N)) | String | 1000 | True | 270.004 ns | 52.1485 ns | 2.8584 ns | - | 48 | | SortedDictionary | O(log(N)) | String | 1000 | True | 281.324 ns | 66.7073 ns | 3.6565 ns | - | 49 | | SortedSet | O(log(N)) | String | 1000 | True | 289.570 ns | 59.6427 ns | 3.2692 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **False** | **3,005.547 ns** | **436.2414 ns** | **23.9119 ns** | **-** | 52 | | ImmutableArray | O(N) | String | 1000 | False | 3,938.770 ns | 526.2674 ns | 28.8465 ns | - | 53 | | List | O(N) | String | 1000 | False | 4,002.468 ns | 646.8517 ns | 35.4561 ns | - | 54 | | Array | O(N) | String | 1000 | False | 4,006.808 ns | 218.9723 ns | 12.0026 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **True** | **1,435.280 ns** | **715.1145 ns** | **39.1978 ns** | **-** | 57 | | ImmutableArray | O(N) | String | 1000 | True | 1,789.514 ns | 753.6574 ns | 41.3105 ns | - | 58 | | List | O(N) | String | 1000 | True | 1,826.351 ns | 227.0355 ns | 12.4446 ns | - | 59 | | Array | O(N) | String | 1000 | True | 1,831.162 ns | 403.4804 ns | 22.1161 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (final)/Benchmarks.TryGetValueBenchmark_StructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------- |------- |-------- |-------------:|--------------:|-----------:|----------:| 15 | | **Dictionary** | **O(1)** | **StructInts** | **1000** | **False** | **19.37 ns** | **4.722 ns** | **0.259 ns** | **32 B** | 16 | | FrozenDictionary | O(1) | StructInts | 1000 | False | 19.79 ns | 7.674 ns | 0.421 ns | 32 B | 17 | | FrozenSet | O(1) | StructInts | 1000 | False | 20.44 ns | 3.003 ns | 0.165 ns | 32 B | 18 | | HashSet | O(1) | StructInts | 1000 | False | 22.08 ns | 0.575 ns | 0.031 ns | 32 B | 19 | | ImmutableDictionary | O(1) | StructInts | 1000 | False | 26.32 ns | 5.736 ns | 0.314 ns | 32 B | 20 | | ImmutableHashSet | O(1) | StructInts | 1000 | False | 27.27 ns | 5.036 ns | 0.276 ns | 32 B | 21 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | False | 33.32 ns | 8.021 ns | 0.440 ns | 32 B | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **StructInts** | **1000** | **True** | **34.89 ns** | **4.106 ns** | **0.225 ns** | **96 B** | 24 | | Dictionary | O(1) | StructInts | 1000 | True | 35.81 ns | 5.208 ns | 0.285 ns | 96 B | 25 | | HashSet | O(1) | StructInts | 1000 | True | 36.13 ns | 21.056 ns | 1.154 ns | 96 B | 26 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | True | 39.45 ns | 20.077 ns | 1.101 ns | 96 B | 27 | | ImmutableHashSet | O(1) | StructInts | 1000 | True | 39.89 ns | 15.302 ns | 0.839 ns | 96 B | 28 | | ImmutableDictionary | O(1) | StructInts | 1000 | True | 40.20 ns | 20.036 ns | 1.098 ns | 96 B | 29 | | FrozenSet | O(1) | StructInts | 1000 | True | 45.59 ns | 18.131 ns | 0.994 ns | 96 B | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **False** | **12.72 ns** | **5.499 ns** | **0.301 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.01 ns | 1.381 ns | 0.076 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.09 ns | 1.804 ns | 0.099 ns | - | 34 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.36 ns | 7.034 ns | 0.386 ns | - | 35 | | SortedList | O(log(N)) | StructInts | 1000 | False | 23.61 ns | 1.590 ns | 0.087 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | StructInts | 1000 | False | 27.48 ns | 2.739 ns | 0.150 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 36.04 ns | 9.127 ns | 0.500 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | False | 36.35 ns | 0.942 ns | 0.052 ns | - | 39 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | False | 36.37 ns | 3.093 ns | 0.170 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **True** | **18.54 ns** | **3.569 ns** | **0.196 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.32 ns | 1.372 ns | 0.075 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.34 ns | 5.513 ns | 0.302 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.60 ns | 2.491 ns | 0.137 ns | - | 45 | | SortedList | O(log(N)) | StructInts | 1000 | True | 26.04 ns | 0.961 ns | 0.053 ns | 32 B | 46 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | True | 26.37 ns | 6.991 ns | 0.383 ns | - | 47 | | SortedDictionary | O(log(N)) | StructInts | 1000 | True | 27.64 ns | 4.194 ns | 0.230 ns | 32 B | 48 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | True | 29.35 ns | 2.403 ns | 0.132 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 31.13 ns | 6.216 ns | 0.341 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **StructInts** | **1000** | **False** | **12,254.54 ns** | **12,885.831 ns** | **706.316 ns** | **64000 B** | 52 | | Array | O(N) | StructInts | 1000 | False | 12,541.77 ns | 16,640.837 ns | 912.140 ns | 64000 B | 53 | | List | O(N) | StructInts | 1000 | False | 12,764.38 ns | 10,572.542 ns | 579.517 ns | 64000 B | 54 | | ImmutableArray | O(N) | StructInts | 1000 | False | 12,889.71 ns | 12,221.754 ns | 669.916 ns | 64000 B | 55 | | | | | | | | | | | 56 | | **List** | **O(N)** | **StructInts** | **1000** | **True** | **6,091.29 ns** | **5,640.174 ns** | **309.157 ns** | **30901 B** | 57 | | ReadOnlyCollection | O(N) | StructInts | 1000 | True | 6,179.42 ns | 5,716.694 ns | 313.351 ns | 30901 B | 58 | | Array | O(N) | StructInts | 1000 | True | 6,261.18 ns | 7,441.955 ns | 407.919 ns | 30901 B | 59 | | ImmutableArray | O(N) | StructInts | 1000 | True | 6,350.76 ns | 8,862.417 ns | 485.779 ns | 30901 B | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.ContainsBenchmark_ClassInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |---------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **ClassInts** | **1000** | **False** | **3.816 ns** | **0.3439 ns** | **0.0188 ns** | **-** | 16 | | FrozenDictionary | O(1) | ClassInts | 1000 | False | 3.970 ns | 0.8071 ns | 0.0442 ns | - | 17 | | Dictionary | O(1) | ClassInts | 1000 | False | 5.605 ns | 0.5061 ns | 0.0277 ns | - | 18 | | HashSet | O(1) | ClassInts | 1000 | False | 5.896 ns | 0.8437 ns | 0.0462 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | False | 7.707 ns | 0.5068 ns | 0.0278 ns | - | 20 | | ImmutableDictionary | O(1) | ClassInts | 1000 | False | 10.967 ns | 0.5921 ns | 0.0325 ns | - | 21 | | ImmutableHashSet | O(1) | ClassInts | 1000 | False | 24.802 ns | 2.6348 ns | 0.1444 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **ClassInts** | **1000** | **True** | **7.293 ns** | **0.9093 ns** | **0.0498 ns** | **-** | 24 | | FrozenDictionary | O(1) | ClassInts | 1000 | True | 7.667 ns | 2.8821 ns | 0.1580 ns | - | 25 | | HashSet | O(1) | ClassInts | 1000 | True | 9.332 ns | 0.7328 ns | 0.0402 ns | - | 26 | | Dictionary | O(1) | ClassInts | 1000 | True | 10.268 ns | 1.6772 ns | 0.0919 ns | - | 27 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | True | 11.855 ns | 2.1780 ns | 0.1194 ns | - | 28 | | ImmutableDictionary | O(1) | ClassInts | 1000 | True | 17.843 ns | 4.8202 ns | 0.2642 ns | - | 29 | | ImmutableHashSet | O(1) | ClassInts | 1000 | True | 28.555 ns | 3.5986 ns | 0.1973 ns | - | 30 | | | | | | | | | | | 31 | | **'Array (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **False** | **36.756 ns** | **7.9028 ns** | **0.4332 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 37.883 ns | 12.6570 ns | 0.6938 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 39.942 ns | 1.4205 ns | 0.0779 ns | - | 34 | | SortedSet | O(log(N)) | ClassInts | 1000 | False | 40.534 ns | 11.2143 ns | 0.6147 ns | - | 35 | | SortedList | O(log(N)) | ClassInts | 1000 | False | 46.525 ns | 12.5093 ns | 0.6857 ns | - | 36 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | False | 50.695 ns | 1.1834 ns | 0.0649 ns | - | 37 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | False | 52.178 ns | 2.5300 ns | 0.1387 ns | - | 38 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | False | 63.056 ns | 10.0247 ns | 0.5495 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 77.122 ns | 19.9195 ns | 1.0919 ns | - | 40 | | | | | | | | | | | 41 | | **'Array (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **True** | **36.618 ns** | **2.7424 ns** | **0.1503 ns** | **-** | 42 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 37.077 ns | 11.5146 ns | 0.6312 ns | - | 43 | | SortedSet | O(log(N)) | ClassInts | 1000 | True | 37.702 ns | 8.5544 ns | 0.4689 ns | - | 44 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 39.211 ns | 1.6640 ns | 0.0912 ns | - | 45 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | True | 41.586 ns | 6.6197 ns | 0.3628 ns | - | 46 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | True | 42.858 ns | 3.6642 ns | 0.2008 ns | - | 47 | | SortedList | O(log(N)) | ClassInts | 1000 | True | 43.436 ns | 6.7912 ns | 0.3722 ns | - | 48 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | True | 58.380 ns | 2.8560 ns | 0.1565 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 64.249 ns | 3.4480 ns | 0.1890 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **False** | **773.154 ns** | **161.5290 ns** | **8.8539 ns** | **-** | 52 | | Array | O(N) | ClassInts | 1000 | False | 1,495.015 ns | 156.0190 ns | 8.5519 ns | - | 53 | | List | O(N) | ClassInts | 1000 | False | 1,734.703 ns | 135.2084 ns | 7.4112 ns | - | 54 | | ImmutableArray | O(N) | ClassInts | 1000 | False | 1,762.379 ns | 452.0526 ns | 24.7785 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **True** | **378.222 ns** | **92.7520 ns** | **5.0840 ns** | **-** | 57 | | Array | O(N) | ClassInts | 1000 | True | 722.915 ns | 62.4702 ns | 3.4242 ns | - | 58 | | List | O(N) | ClassInts | 1000 | True | 841.805 ns | 201.8899 ns | 11.0663 ns | - | 59 | | ImmutableArray | O(N) | ClassInts | 1000 | True | 850.812 ns | 122.4955 ns | 6.7144 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.ContainsBenchmark_ClassStrings_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |------------- |------- |-------- |------------:|-------------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **ClassStrings** | **1000** | **False** | **23.75 ns** | **2.486 ns** | **0.136 ns** | **-** | 16 | | FrozenDictionary | O(1) | ClassStrings | 1000 | False | 23.77 ns | 2.596 ns | 0.142 ns | - | 17 | | HashSet | O(1) | ClassStrings | 1000 | False | 25.09 ns | 3.944 ns | 0.216 ns | - | 18 | | Dictionary | O(1) | ClassStrings | 1000 | False | 26.48 ns | 2.090 ns | 0.115 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | False | 27.76 ns | 1.982 ns | 0.109 ns | - | 20 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | False | 30.32 ns | 2.906 ns | 0.159 ns | - | 21 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | False | 40.72 ns | 10.356 ns | 0.568 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **ClassStrings** | **1000** | **True** | **27.47 ns** | **1.917 ns** | **0.105 ns** | **-** | 24 | | FrozenDictionary | O(1) | ClassStrings | 1000 | True | 27.90 ns | 1.254 ns | 0.069 ns | - | 25 | | Dictionary | O(1) | ClassStrings | 1000 | True | 29.96 ns | 2.548 ns | 0.140 ns | - | 26 | | HashSet | O(1) | ClassStrings | 1000 | True | 30.39 ns | 3.248 ns | 0.178 ns | - | 27 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | True | 32.11 ns | 4.866 ns | 0.267 ns | - | 28 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | True | 34.77 ns | 2.034 ns | 0.111 ns | - | 29 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | True | 45.61 ns | 7.597 ns | 0.416 ns | - | 30 | | | | | | | | | | | 31 | | **'List (Sorted + BinarySearch)'** | **O(log(N))** | **ClassStrings** | **1000** | **False** | **318.19 ns** | **40.186 ns** | **2.203 ns** | **-** | 32 | | SortedSet | O(log(N)) | ClassStrings | 1000 | False | 318.67 ns | 34.975 ns | 1.917 ns | - | 33 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 320.15 ns | 20.158 ns | 1.105 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 326.21 ns | 57.223 ns | 3.137 ns | - | 35 | | SortedList | O(log(N)) | ClassStrings | 1000 | False | 327.96 ns | 21.865 ns | 1.199 ns | - | 36 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 332.48 ns | 108.409 ns | 5.942 ns | - | 37 | | ImmutableSortedSet | O(log(N)) | ClassStrings | 1000 | False | 333.72 ns | 22.293 ns | 1.222 ns | - | 38 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 364.69 ns | 68.964 ns | 3.780 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 366.50 ns | 47.879 ns | 2.624 ns | - | 40 | | | | | | | | | | | 41 | | **'ImmutableArray (Sorted + BinarySearch)'** | **O(log(N))** | **ClassStrings** | **1000** | **True** | **246.53 ns** | **19.237 ns** | **1.054 ns** | **-** | 42 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 247.97 ns | 40.149 ns | 2.201 ns | - | 43 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 252.79 ns | 63.682 ns | 3.491 ns | - | 44 | | ImmutableSortedSet | O(log(N)) | ClassStrings | 1000 | True | 253.33 ns | 65.397 ns | 3.585 ns | - | 45 | | SortedList | O(log(N)) | ClassStrings | 1000 | True | 259.50 ns | 16.546 ns | 0.907 ns | - | 46 | | SortedSet | O(log(N)) | ClassStrings | 1000 | True | 266.93 ns | 64.864 ns | 3.555 ns | - | 47 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 278.50 ns | 79.701 ns | 4.369 ns | - | 48 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 290.57 ns | 22.471 ns | 1.232 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 290.76 ns | 17.907 ns | 0.982 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **False** | **791.51 ns** | **141.688 ns** | **7.766 ns** | **-** | 52 | | ImmutableArray | O(N) | ClassStrings | 1000 | False | 3,974.60 ns | 342.106 ns | 18.752 ns | - | 53 | | List | O(N) | ClassStrings | 1000 | False | 4,067.15 ns | 1,557.257 ns | 85.359 ns | - | 54 | | Array | O(N) | ClassStrings | 1000 | False | 4,236.23 ns | 505.064 ns | 27.684 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **True** | **392.40 ns** | **62.709 ns** | **3.437 ns** | **-** | 57 | | ImmutableArray | O(N) | ClassStrings | 1000 | True | 1,914.95 ns | 127.458 ns | 6.986 ns | - | 58 | | Array | O(N) | ClassStrings | 1000 | True | 1,930.61 ns | 353.032 ns | 19.351 ns | - | 59 | | List | O(N) | ClassStrings | 1000 | True | 1,995.30 ns | 1,130.778 ns | 61.982 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.ContainsBenchmark_Int32_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |----------:|-----------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **Int32** | **1000** | **False** | **1.945 ns** | **0.0588 ns** | **0.0032 ns** | **-** | 16 | | FrozenDictionary | O(1) | Int32 | 1000 | False | 2.029 ns | 0.1983 ns | 0.0109 ns | - | 17 | | Dictionary | O(1) | Int32 | 1000 | False | 3.151 ns | 0.2901 ns | 0.0159 ns | - | 18 | | HashSet | O(1) | Int32 | 1000 | False | 3.557 ns | 0.2335 ns | 0.0128 ns | - | 19 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | False | 3.620 ns | 0.2061 ns | 0.0113 ns | - | 20 | | ImmutableDictionary | O(1) | Int32 | 1000 | False | 6.936 ns | 0.9263 ns | 0.0508 ns | - | 21 | | ImmutableHashSet | O(1) | Int32 | 1000 | False | 7.002 ns | 1.1803 ns | 0.0647 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **Int32** | **1000** | **True** | **2.105 ns** | **0.2321 ns** | **0.0127 ns** | **-** | 24 | | FrozenSet | O(1) | Int32 | 1000 | True | 2.348 ns | 0.6690 ns | 0.0367 ns | - | 25 | | HashSet | O(1) | Int32 | 1000 | True | 3.854 ns | 1.0097 ns | 0.0553 ns | - | 26 | | Dictionary | O(1) | Int32 | 1000 | True | 3.885 ns | 0.2723 ns | 0.0149 ns | - | 27 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | True | 4.289 ns | 0.4145 ns | 0.0227 ns | - | 28 | | ImmutableDictionary | O(1) | Int32 | 1000 | True | 6.075 ns | 2.0104 ns | 0.1102 ns | - | 29 | | ImmutableHashSet | O(1) | Int32 | 1000 | True | 6.100 ns | 2.0314 ns | 0.1113 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **False** | **12.098 ns** | **1.9697 ns** | **0.1080 ns** | **-** | 32 | | SortedList | O(log(N)) | Int32 | 1000 | False | 14.066 ns | 4.9435 ns | 0.2710 ns | - | 33 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.108 ns | 1.4230 ns | 0.0780 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.658 ns | 3.4903 ns | 0.1913 ns | - | 35 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 19.406 ns | 7.5607 ns | 0.4144 ns | - | 36 | | SortedDictionary | O(log(N)) | Int32 | 1000 | False | 23.119 ns | 3.2485 ns | 0.1781 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | False | 23.298 ns | 1.0291 ns | 0.0564 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | False | 23.324 ns | 2.6545 ns | 0.1455 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 28.372 ns | 6.6657 ns | 0.3654 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **True** | **11.001 ns** | **2.1815 ns** | **0.1196 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.082 ns | 2.2910 ns | 0.1256 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.183 ns | 1.5786 ns | 0.0865 ns | - | 44 | | SortedList | O(log(N)) | Int32 | 1000 | True | 14.344 ns | 0.4976 ns | 0.0273 ns | - | 45 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 14.669 ns | 1.7234 ns | 0.0945 ns | - | 46 | | SortedDictionary | O(log(N)) | Int32 | 1000 | True | 16.904 ns | 1.2891 ns | 0.0707 ns | - | 47 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | True | 18.442 ns | 1.7855 ns | 0.0979 ns | - | 48 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | True | 18.480 ns | 4.0187 ns | 0.2203 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 24.008 ns | 7.1657 ns | 0.3928 ns | - | 50 | | | | | | | | | | | 51 | | **List** | **O(N)** | **Int32** | **1000** | **False** | **43.877 ns** | **8.4752 ns** | **0.4646 ns** | **-** | 52 | | ReadOnlyCollection | O(N) | Int32 | 1000 | False | 44.524 ns | 4.7096 ns | 0.2581 ns | - | 53 | | ImmutableArray | O(N) | Int32 | 1000 | False | 68.765 ns | 10.3856 ns | 0.5693 ns | - | 54 | | Array | O(N) | Int32 | 1000 | False | 70.900 ns | 79.2658 ns | 4.3448 ns | - | 55 | | | | | | | | | | | 56 | | **List** | **O(N)** | **Int32** | **1000** | **True** | **29.495 ns** | **11.5223 ns** | **0.6316 ns** | **-** | 57 | | Array | O(N) | Int32 | 1000 | True | 30.105 ns | 3.9241 ns | 0.2151 ns | - | 58 | | ReadOnlyCollection | O(N) | Int32 | 1000 | True | 30.159 ns | 3.3028 ns | 0.1810 ns | - | 59 | | ImmutableArray | O(N) | Int32 | 1000 | True | 30.334 ns | 1.9629 ns | 0.1076 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.ContainsBenchmark_RecordStructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------------- |------- |-------- |-----------:|------------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **RecordStructInts** | **1000** | **False** | **2.595 ns** | **0.2810 ns** | **0.0154 ns** | **-** | 16 | | FrozenDictionary | O(1) | RecordStructInts | 1000 | False | 2.598 ns | 0.3018 ns | 0.0165 ns | - | 17 | | Dictionary | O(1) | RecordStructInts | 1000 | False | 4.380 ns | 0.2512 ns | 0.0138 ns | - | 18 | | HashSet | O(1) | RecordStructInts | 1000 | False | 4.425 ns | 0.1250 ns | 0.0069 ns | - | 19 | | ReadOnlyDictionary | O(1) | RecordStructInts | 1000 | False | 4.576 ns | 0.2102 ns | 0.0115 ns | - | 20 | | ImmutableDictionary | O(1) | RecordStructInts | 1000 | False | 7.573 ns | 1.0966 ns | 0.0601 ns | - | 21 | | ImmutableHashSet | O(1) | RecordStructInts | 1000 | False | 7.642 ns | 1.5060 ns | 0.0826 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **RecordStructInts** | **1000** | **True** | **3.618 ns** | **0.3391 ns** | **0.0186 ns** | **-** | 24 | | FrozenDictionary | O(1) | RecordStructInts | 1000 | True | 3.785 ns | 0.8025 ns | 0.0440 ns | - | 25 | | HashSet | O(1) | RecordStructInts | 1000 | True | 4.911 ns | 1.7936 ns | 0.0983 ns | - | 26 | | Dictionary | O(1) | RecordStructInts | 1000 | True | 4.986 ns | 0.1465 ns | 0.0080 ns | - | 27 | | ReadOnlyDictionary | O(1) | RecordStructInts | 1000 | True | 5.399 ns | 0.4077 ns | 0.0223 ns | - | 28 | | ImmutableHashSet | O(1) | RecordStructInts | 1000 | True | 7.693 ns | 2.5277 ns | 0.1386 ns | - | 29 | | ImmutableDictionary | O(1) | RecordStructInts | 1000 | True | 7.904 ns | 1.8532 ns | 0.1016 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **RecordStructInts** | **1000** | **False** | **13.978 ns** | **0.7222 ns** | **0.0396 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 18.674 ns | 1.9552 ns | 0.1072 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 18.848 ns | 1.2010 ns | 0.0658 ns | - | 34 | | 'List (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 19.021 ns | 2.6577 ns | 0.1457 ns | - | 35 | | SortedList | O(log(N)) | RecordStructInts | 1000 | False | 23.771 ns | 8.3139 ns | 0.4557 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | RecordStructInts | 1000 | False | 24.974 ns | 2.8214 ns | 0.1547 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | False | 31.460 ns | 3.6933 ns | 0.2024 ns | - | 38 | | ImmutableSortedDictionary | O(log(N)) | RecordStructInts | 1000 | False | 36.904 ns | 6.3120 ns | 0.3460 ns | - | 39 | | ImmutableSortedSet | O(log(N)) | RecordStructInts | 1000 | False | 37.512 ns | 9.0715 ns | 0.4972 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **RecordStructInts** | **1000** | **True** | **17.640 ns** | **4.1919 ns** | **0.2298 ns** | **-** | 42 | | 'List (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.606 ns | 2.4490 ns | 0.1342 ns | - | 43 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.637 ns | 2.3828 ns | 0.1306 ns | - | 44 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 20.843 ns | 1.4851 ns | 0.0814 ns | - | 45 | | SortedList | O(log(N)) | RecordStructInts | 1000 | True | 26.691 ns | 8.7106 ns | 0.4775 ns | 32 B | 46 | | ImmutableSortedDictionary | O(log(N)) | RecordStructInts | 1000 | True | 27.080 ns | 7.2256 ns | 0.3961 ns | - | 47 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | RecordStructInts | 1000 | True | 27.141 ns | 3.5392 ns | 0.1940 ns | - | 48 | | SortedDictionary | O(log(N)) | RecordStructInts | 1000 | True | 27.407 ns | 7.4406 ns | 0.4078 ns | 32 B | 49 | | ImmutableSortedSet | O(log(N)) | RecordStructInts | 1000 | True | 29.574 ns | 3.2711 ns | 0.1793 ns | - | 50 | | | | | | | | | | | 51 | | **Array** | **O(N)** | **RecordStructInts** | **1000** | **False** | **484.841 ns** | **51.5342 ns** | **2.8248 ns** | **-** | 52 | | ImmutableArray | O(N) | RecordStructInts | 1000 | False | 493.708 ns | 63.8378 ns | 3.4992 ns | - | 53 | | List | O(N) | RecordStructInts | 1000 | False | 495.131 ns | 161.4268 ns | 8.8483 ns | - | 54 | | ReadOnlyCollection | O(N) | RecordStructInts | 1000 | False | 512.845 ns | 119.1040 ns | 6.5285 ns | - | 55 | | | | | | | | | | | 56 | | **List** | **O(N)** | **RecordStructInts** | **1000** | **True** | **252.419 ns** | **24.8989 ns** | **1.3648 ns** | **-** | 57 | | ReadOnlyCollection | O(N) | RecordStructInts | 1000 | True | 253.197 ns | 21.8176 ns | 1.1959 ns | - | 58 | | Array | O(N) | RecordStructInts | 1000 | True | 255.642 ns | 34.3234 ns | 1.8814 ns | - | 59 | | ImmutableArray | O(N) | RecordStructInts | 1000 | True | 257.205 ns | 12.2996 ns | 0.6742 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.ContainsBenchmark_String_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **String** | **1000** | **False** | **4.308 ns** | **0.0803 ns** | **0.0044 ns** | **-** | 16 | | FrozenDictionary | O(1) | String | 1000 | False | 4.405 ns | 0.4932 ns | 0.0270 ns | - | 17 | | HashSet | O(1) | String | 1000 | False | 6.841 ns | 1.0581 ns | 0.0580 ns | - | 18 | | Dictionary | O(1) | String | 1000 | False | 7.015 ns | 1.8951 ns | 0.1039 ns | - | 19 | | ReadOnlyDictionary | O(1) | String | 1000 | False | 8.961 ns | 2.6484 ns | 0.1452 ns | - | 20 | | ImmutableDictionary | O(1) | String | 1000 | False | 16.405 ns | 2.8413 ns | 0.1557 ns | - | 21 | | ImmutableHashSet | O(1) | String | 1000 | False | 26.570 ns | 3.4740 ns | 0.1904 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **String** | **1000** | **True** | **4.452 ns** | **0.1191 ns** | **0.0065 ns** | **-** | 24 | | FrozenDictionary | O(1) | String | 1000 | True | 4.987 ns | 0.4987 ns | 0.0273 ns | - | 25 | | HashSet | O(1) | String | 1000 | True | 8.720 ns | 0.2512 ns | 0.0138 ns | - | 26 | | Dictionary | O(1) | String | 1000 | True | 8.825 ns | 1.4643 ns | 0.0803 ns | - | 27 | | ReadOnlyDictionary | O(1) | String | 1000 | True | 11.300 ns | 2.2122 ns | 0.1213 ns | - | 28 | | ImmutableDictionary | O(1) | String | 1000 | True | 21.104 ns | 2.9163 ns | 0.1599 ns | - | 29 | | ImmutableHashSet | O(1) | String | 1000 | True | 28.374 ns | 1.4515 ns | 0.0796 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **String** | **1000** | **False** | **307.629 ns** | **40.8524 ns** | **2.2393 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 312.884 ns | 14.2113 ns | 0.7790 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 313.269 ns | 57.7894 ns | 3.1676 ns | - | 34 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 314.854 ns | 105.9571 ns | 5.8079 ns | - | 35 | | SortedList | O(log(N)) | String | 1000 | False | 322.710 ns | 107.3378 ns | 5.8835 ns | - | 36 | | ImmutableSortedSet | O(log(N)) | String | 1000 | False | 323.908 ns | 61.6276 ns | 3.3780 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | String | 1000 | False | 330.652 ns | 116.2749 ns | 6.3734 ns | - | 38 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 356.776 ns | 58.3859 ns | 3.2003 ns | - | 39 | | SortedDictionary | O(log(N)) | String | 1000 | False | 361.296 ns | 118.4797 ns | 6.4943 ns | - | 40 | | | | | | | | | | | 41 | | **ImmutableSortedDictionary** | **O(log(N))** | **String** | **1000** | **True** | **241.350 ns** | **79.5247 ns** | **4.3590 ns** | **-** | 42 | | ImmutableSortedSet | O(log(N)) | String | 1000 | True | 248.392 ns | 79.2214 ns | 4.3424 ns | - | 43 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 264.561 ns | 56.0615 ns | 3.0729 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 266.752 ns | 27.9816 ns | 1.5338 ns | - | 45 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 267.570 ns | 31.6018 ns | 1.7322 ns | - | 46 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 268.204 ns | 102.9788 ns | 5.6446 ns | - | 47 | | SortedList | O(log(N)) | String | 1000 | True | 271.979 ns | 22.9028 ns | 1.2554 ns | - | 48 | | SortedSet | O(log(N)) | String | 1000 | True | 272.019 ns | 76.0691 ns | 4.1696 ns | - | 49 | | SortedDictionary | O(log(N)) | String | 1000 | True | 280.641 ns | 10.9002 ns | 0.5975 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **False** | **2,851.432 ns** | **683.4577 ns** | **37.4626 ns** | **-** | 52 | | List | O(N) | String | 1000 | False | 3,747.693 ns | 485.0937 ns | 26.5896 ns | - | 53 | | ImmutableArray | O(N) | String | 1000 | False | 4,042.309 ns | 569.2436 ns | 31.2022 ns | - | 54 | | Array | O(N) | String | 1000 | False | 4,171.897 ns | 475.1176 ns | 26.0428 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **True** | **1,392.430 ns** | **60.8564 ns** | **3.3357 ns** | **-** | 57 | | List | O(N) | String | 1000 | True | 1,836.948 ns | 69.8249 ns | 3.8273 ns | - | 58 | | Array | O(N) | String | 1000 | True | 1,838.527 ns | 646.2116 ns | 35.4210 ns | - | 59 | | ImmutableArray | O(N) | String | 1000 | True | 1,869.762 ns | 776.7829 ns | 42.5781 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.ContainsBenchmark_StructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------- |------- |-------- |-------------:|--------------:|-------------:|----------:| 15 | | **FrozenSet** | **O(1)** | **StructInts** | **1000** | **False** | **20.32 ns** | **5.697 ns** | **0.312 ns** | **32 B** | 16 | | FrozenDictionary | O(1) | StructInts | 1000 | False | 20.49 ns | 3.656 ns | 0.200 ns | 32 B | 17 | | HashSet | O(1) | StructInts | 1000 | False | 22.29 ns | 7.726 ns | 0.423 ns | 32 B | 18 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | False | 22.84 ns | 0.328 ns | 0.018 ns | 32 B | 19 | | Dictionary | O(1) | StructInts | 1000 | False | 24.19 ns | 2.166 ns | 0.119 ns | 32 B | 20 | | ImmutableDictionary | O(1) | StructInts | 1000 | False | 25.33 ns | 3.162 ns | 0.173 ns | 32 B | 21 | | ImmutableHashSet | O(1) | StructInts | 1000 | False | 27.69 ns | 8.744 ns | 0.479 ns | 32 B | 22 | | | | | | | | | | | 23 | | **FrozenSet** | **O(1)** | **StructInts** | **1000** | **True** | **35.92 ns** | **24.385 ns** | **1.337 ns** | **96 B** | 24 | | FrozenDictionary | O(1) | StructInts | 1000 | True | 36.45 ns | 21.510 ns | 1.179 ns | 96 B | 25 | | HashSet | O(1) | StructInts | 1000 | True | 39.24 ns | 29.821 ns | 1.635 ns | 96 B | 26 | | ImmutableDictionary | O(1) | StructInts | 1000 | True | 40.29 ns | 22.601 ns | 1.239 ns | 96 B | 27 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | True | 40.91 ns | 13.843 ns | 0.759 ns | 96 B | 28 | | ImmutableHashSet | O(1) | StructInts | 1000 | True | 41.37 ns | 25.692 ns | 1.408 ns | 96 B | 29 | | Dictionary | O(1) | StructInts | 1000 | True | 41.99 ns | 19.671 ns | 1.078 ns | 96 B | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **False** | **12.96 ns** | **7.283 ns** | **0.399 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 18.93 ns | 2.100 ns | 0.115 ns | - | 33 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.17 ns | 2.258 ns | 0.124 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.19 ns | 1.790 ns | 0.098 ns | - | 35 | | SortedList | O(log(N)) | StructInts | 1000 | False | 23.86 ns | 6.965 ns | 0.382 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | StructInts | 1000 | False | 24.52 ns | 6.728 ns | 0.369 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 31.48 ns | 7.400 ns | 0.406 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | False | 37.11 ns | 5.834 ns | 0.320 ns | - | 39 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | False | 37.15 ns | 5.070 ns | 0.278 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **True** | **17.81 ns** | **3.540 ns** | **0.194 ns** | **-** | 42 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.24 ns | 4.076 ns | 0.223 ns | - | 43 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.27 ns | 0.536 ns | 0.029 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.60 ns | 4.917 ns | 0.270 ns | - | 45 | | SortedDictionary | O(log(N)) | StructInts | 1000 | True | 24.90 ns | 1.297 ns | 0.071 ns | 32 B | 46 | | SortedList | O(log(N)) | StructInts | 1000 | True | 25.58 ns | 3.680 ns | 0.202 ns | 32 B | 47 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 27.15 ns | 2.459 ns | 0.135 ns | - | 48 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | True | 29.41 ns | 1.524 ns | 0.084 ns | - | 49 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | True | 29.56 ns | 6.592 ns | 0.361 ns | - | 50 | | | | | | | | | | | 51 | | **Array** | **O(N)** | **StructInts** | **1000** | **False** | **12,463.03 ns** | **11,691.582 ns** | **640.855 ns** | **64000 B** | 52 | | List | O(N) | StructInts | 1000 | False | 13,190.33 ns | 9,086.595 ns | 498.067 ns | 64000 B | 53 | | ImmutableArray | O(N) | StructInts | 1000 | False | 13,202.27 ns | 20,087.818 ns | 1,101.081 ns | 64000 B | 54 | | ReadOnlyCollection | O(N) | StructInts | 1000 | False | 13,302.69 ns | 15,827.541 ns | 867.561 ns | 64000 B | 55 | | | | | | | | | | | 56 | | **Array** | **O(N)** | **StructInts** | **1000** | **True** | **6,322.55 ns** | **5,531.420 ns** | **303.196 ns** | **30901 B** | 57 | | ImmutableArray | O(N) | StructInts | 1000 | True | 6,373.33 ns | 5,837.792 ns | 319.989 ns | 30901 B | 58 | | List | O(N) | StructInts | 1000 | True | 6,377.23 ns | 4,884.856 ns | 267.755 ns | 30901 B | 59 | | ReadOnlyCollection | O(N) | StructInts | 1000 | True | 6,487.09 ns | 7,103.222 ns | 389.352 ns | 30901 B | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.TryGetValueBenchmark_ClassInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |---------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **ClassInts** | **1000** | **False** | **3.893 ns** | **0.1170 ns** | **0.0064 ns** | **-** | 16 | | Dictionary | O(1) | ClassInts | 1000 | False | 5.800 ns | 0.6555 ns | 0.0359 ns | - | 17 | | HashSet | O(1) | ClassInts | 1000 | False | 6.058 ns | 0.5716 ns | 0.0313 ns | - | 18 | | FrozenSet | O(1) | ClassInts | 1000 | False | 7.170 ns | 0.7202 ns | 0.0395 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | False | 8.227 ns | 0.4546 ns | 0.0249 ns | - | 20 | | ImmutableHashSet | O(1) | ClassInts | 1000 | False | 10.564 ns | 2.0148 ns | 0.1104 ns | - | 21 | | ImmutableDictionary | O(1) | ClassInts | 1000 | False | 11.503 ns | 2.1492 ns | 0.1178 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **ClassInts** | **1000** | **True** | **7.734 ns** | **1.7179 ns** | **0.0942 ns** | **-** | 24 | | Dictionary | O(1) | ClassInts | 1000 | True | 9.370 ns | 1.2367 ns | 0.0678 ns | - | 25 | | HashSet | O(1) | ClassInts | 1000 | True | 9.552 ns | 1.4827 ns | 0.0813 ns | - | 26 | | ReadOnlyDictionary | O(1) | ClassInts | 1000 | True | 12.288 ns | 2.8657 ns | 0.1571 ns | - | 27 | | FrozenSet | O(1) | ClassInts | 1000 | True | 13.617 ns | 1.1161 ns | 0.0612 ns | - | 28 | | ImmutableHashSet | O(1) | ClassInts | 1000 | True | 15.310 ns | 5.3803 ns | 0.2949 ns | - | 29 | | ImmutableDictionary | O(1) | ClassInts | 1000 | True | 17.573 ns | 0.7587 ns | 0.0416 ns | - | 30 | | | | | | | | | | | 31 | | **'List (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **False** | **36.647 ns** | **9.3205 ns** | **0.5109 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 37.925 ns | 5.4951 ns | 0.3012 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 39.116 ns | 16.9538 ns | 0.9293 ns | - | 34 | | SortedSet | O(log(N)) | ClassInts | 1000 | False | 42.620 ns | 8.3177 ns | 0.4559 ns | - | 35 | | SortedList | O(log(N)) | ClassInts | 1000 | False | 48.149 ns | 42.0762 ns | 2.3063 ns | - | 36 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | False | 48.278 ns | 11.8497 ns | 0.6495 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | False | 52.262 ns | 4.9041 ns | 0.2688 ns | - | 38 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | False | 60.603 ns | 4.7155 ns | 0.2585 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | False | 79.511 ns | 20.5448 ns | 1.1261 ns | - | 40 | | | | | | | | | | | 41 | | **'List (Sorted + BinarySearch)'** | **O(log(N))** | **ClassInts** | **1000** | **True** | **36.386 ns** | **5.4246 ns** | **0.2973 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 38.523 ns | 1.1629 ns | 0.0637 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 39.157 ns | 7.1774 ns | 0.3934 ns | - | 44 | | ImmutableSortedSet | O(log(N)) | ClassInts | 1000 | True | 39.679 ns | 2.4508 ns | 0.1343 ns | - | 45 | | SortedSet | O(log(N)) | ClassInts | 1000 | True | 39.951 ns | 15.2387 ns | 0.8353 ns | - | 46 | | ImmutableSortedDictionary | O(log(N)) | ClassInts | 1000 | True | 42.528 ns | 4.8931 ns | 0.2682 ns | - | 47 | | SortedList | O(log(N)) | ClassInts | 1000 | True | 43.552 ns | 5.2954 ns | 0.2903 ns | - | 48 | | SortedDictionary | O(log(N)) | ClassInts | 1000 | True | 59.154 ns | 9.6093 ns | 0.5267 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassInts | 1000 | True | 68.583 ns | 4.8163 ns | 0.2640 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **False** | **773.975 ns** | **105.2108 ns** | **5.7670 ns** | **-** | 52 | | ImmutableArray | O(N) | ClassInts | 1000 | False | 1,504.838 ns | 258.8998 ns | 14.1912 ns | - | 53 | | List | O(N) | ClassInts | 1000 | False | 1,508.505 ns | 109.9052 ns | 6.0243 ns | - | 54 | | Array | O(N) | ClassInts | 1000 | False | 1,736.114 ns | 224.0401 ns | 12.2804 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassInts** | **1000** | **True** | **265.686 ns** | **38.7472 ns** | **2.1239 ns** | **-** | 57 | | List | O(N) | ClassInts | 1000 | True | 726.899 ns | 89.2420 ns | 4.8917 ns | - | 58 | | Array | O(N) | ClassInts | 1000 | True | 841.566 ns | 78.2787 ns | 4.2907 ns | - | 59 | | ImmutableArray | O(N) | ClassInts | 1000 | True | 852.207 ns | 251.4988 ns | 13.7855 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.TryGetValueBenchmark_ClassStrings_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |------------- |------- |-------- |------------:|-------------:|----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **ClassStrings** | **1000** | **False** | **23.98 ns** | **0.452 ns** | **0.025 ns** | **-** | 16 | | FrozenSet | O(1) | ClassStrings | 1000 | False | 26.46 ns | 0.456 ns | 0.025 ns | - | 17 | | HashSet | O(1) | ClassStrings | 1000 | False | 26.76 ns | 0.408 ns | 0.022 ns | - | 18 | | Dictionary | O(1) | ClassStrings | 1000 | False | 26.80 ns | 1.645 ns | 0.090 ns | - | 19 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | False | 27.73 ns | 2.351 ns | 0.129 ns | - | 20 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | False | 30.47 ns | 2.660 ns | 0.146 ns | - | 21 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | False | 30.72 ns | 0.623 ns | 0.034 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **ClassStrings** | **1000** | **True** | **27.86 ns** | **4.357 ns** | **0.239 ns** | **-** | 24 | | Dictionary | O(1) | ClassStrings | 1000 | True | 30.29 ns | 6.321 ns | 0.346 ns | - | 25 | | HashSet | O(1) | ClassStrings | 1000 | True | 30.82 ns | 5.325 ns | 0.292 ns | - | 26 | | ReadOnlyDictionary | O(1) | ClassStrings | 1000 | True | 33.20 ns | 8.883 ns | 0.487 ns | - | 27 | | FrozenSet | O(1) | ClassStrings | 1000 | True | 33.70 ns | 5.565 ns | 0.305 ns | - | 28 | | ImmutableHashSet | O(1) | ClassStrings | 1000 | True | 34.40 ns | 2.157 ns | 0.118 ns | - | 29 | | ImmutableDictionary | O(1) | ClassStrings | 1000 | True | 35.85 ns | 4.065 ns | 0.223 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **ClassStrings** | **1000** | **False** | **321.25 ns** | **66.400 ns** | **3.640 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 323.10 ns | 96.490 ns | 5.289 ns | - | 33 | | SortedList | O(log(N)) | ClassStrings | 1000 | False | 335.78 ns | 106.597 ns | 5.843 ns | - | 34 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 336.69 ns | 38.143 ns | 2.091 ns | - | 35 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 337.24 ns | 81.554 ns | 4.470 ns | - | 36 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 338.19 ns | 37.666 ns | 2.065 ns | - | 37 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | False | 362.20 ns | 9.752 ns | 0.535 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | ClassStrings | 1000 | False | 362.93 ns | 12.923 ns | 0.708 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | False | 380.81 ns | 42.232 ns | 2.315 ns | - | 40 | | | | | | | | | | | 41 | | **ImmutableSortedSet** | **O(log(N))** | **ClassStrings** | **1000** | **True** | **259.80 ns** | **19.087 ns** | **1.046 ns** | **-** | 42 | | ImmutableSortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 260.24 ns | 32.740 ns | 1.795 ns | - | 43 | | SortedList | O(log(N)) | ClassStrings | 1000 | True | 266.62 ns | 35.902 ns | 1.968 ns | - | 44 | | SortedSet | O(log(N)) | ClassStrings | 1000 | True | 271.12 ns | 31.895 ns | 1.748 ns | - | 45 | | 'List (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 279.69 ns | 37.823 ns | 2.073 ns | - | 46 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 284.16 ns | 61.323 ns | 3.361 ns | - | 47 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 287.29 ns | 22.202 ns | 1.217 ns | - | 48 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | ClassStrings | 1000 | True | 289.97 ns | 49.846 ns | 2.732 ns | - | 49 | | SortedDictionary | O(log(N)) | ClassStrings | 1000 | True | 323.84 ns | 54.871 ns | 3.008 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **False** | **806.45 ns** | **25.769 ns** | **1.412 ns** | **-** | 52 | | ImmutableArray | O(N) | ClassStrings | 1000 | False | 4,104.14 ns | 561.662 ns | 30.787 ns | - | 53 | | Array | O(N) | ClassStrings | 1000 | False | 4,278.42 ns | 1,175.071 ns | 64.410 ns | - | 54 | | List | O(N) | ClassStrings | 1000 | False | 4,405.76 ns | 631.143 ns | 34.595 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **ClassStrings** | **1000** | **True** | **326.04 ns** | **53.764 ns** | **2.947 ns** | **-** | 57 | | List | O(N) | ClassStrings | 1000 | True | 1,956.09 ns | 813.244 ns | 44.577 ns | - | 58 | | ImmutableArray | O(N) | ClassStrings | 1000 | True | 1,983.68 ns | 248.286 ns | 13.609 ns | - | 59 | | Array | O(N) | ClassStrings | 1000 | True | 2,075.47 ns | 640.796 ns | 35.124 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.TryGetValueBenchmark_Int32_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |----------:|----------:|----------:|----------:| 15 | | **FrozenSet** | **O(1)** | **Int32** | **1000** | **False** | **2.017 ns** | **0.1896 ns** | **0.0104 ns** | **-** | 16 | | FrozenDictionary | O(1) | Int32 | 1000 | False | 2.030 ns | 0.1221 ns | 0.0067 ns | - | 17 | | Dictionary | O(1) | Int32 | 1000 | False | 3.391 ns | 0.5301 ns | 0.0291 ns | - | 18 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | False | 3.455 ns | 0.6222 ns | 0.0341 ns | - | 19 | | HashSet | O(1) | Int32 | 1000 | False | 3.481 ns | 0.5842 ns | 0.0320 ns | - | 20 | | ImmutableDictionary | O(1) | Int32 | 1000 | False | 7.248 ns | 3.0504 ns | 0.1672 ns | - | 21 | | ImmutableHashSet | O(1) | Int32 | 1000 | False | 7.340 ns | 2.7137 ns | 0.1487 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **Int32** | **1000** | **True** | **2.095 ns** | **0.2315 ns** | **0.0127 ns** | **-** | 24 | | FrozenSet | O(1) | Int32 | 1000 | True | 2.394 ns | 0.5573 ns | 0.0305 ns | - | 25 | | HashSet | O(1) | Int32 | 1000 | True | 2.853 ns | 0.5433 ns | 0.0298 ns | - | 26 | | Dictionary | O(1) | Int32 | 1000 | True | 4.085 ns | 0.1796 ns | 0.0098 ns | - | 27 | | ReadOnlyDictionary | O(1) | Int32 | 1000 | True | 4.432 ns | 0.6207 ns | 0.0340 ns | - | 28 | | ImmutableDictionary | O(1) | Int32 | 1000 | True | 6.307 ns | 2.3095 ns | 0.1266 ns | - | 29 | | ImmutableHashSet | O(1) | Int32 | 1000 | True | 6.315 ns | 0.9480 ns | 0.0520 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **False** | **11.367 ns** | **2.2254 ns** | **0.1220 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 14.998 ns | 2.6544 ns | 0.1455 ns | - | 33 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.383 ns | 2.5442 ns | 0.1395 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 15.764 ns | 0.6891 ns | 0.0378 ns | - | 35 | | SortedList | O(log(N)) | Int32 | 1000 | False | 16.714 ns | 1.9644 ns | 0.1077 ns | - | 36 | | SortedDictionary | O(log(N)) | Int32 | 1000 | False | 19.917 ns | 1.2177 ns | 0.0667 ns | - | 37 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | False | 23.368 ns | 5.7702 ns | 0.3163 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | False | 24.754 ns | 3.4614 ns | 0.1897 ns | - | 39 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | False | 28.555 ns | 0.5529 ns | 0.0303 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **Int32** | **1000** | **True** | **12.824 ns** | **1.0387 ns** | **0.0569 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.101 ns | 1.0020 ns | 0.0549 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.181 ns | 1.1741 ns | 0.0644 ns | - | 44 | | SortedList | O(log(N)) | Int32 | 1000 | True | 13.182 ns | 1.1688 ns | 0.0641 ns | - | 45 | | 'List (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 13.594 ns | 3.7703 ns | 0.2067 ns | - | 46 | | ImmutableSortedDictionary | O(log(N)) | Int32 | 1000 | True | 18.594 ns | 0.5907 ns | 0.0324 ns | - | 47 | | ImmutableSortedSet | O(log(N)) | Int32 | 1000 | True | 18.637 ns | 0.7645 ns | 0.0419 ns | - | 48 | | SortedDictionary | O(log(N)) | Int32 | 1000 | True | 19.448 ns | 3.0688 ns | 0.1682 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | Int32 | 1000 | True | 27.142 ns | 3.5470 ns | 0.1944 ns | - | 50 | | | | | | | | | | | 51 | | **Array** | **O(N)** | **Int32** | **1000** | **False** | **41.027 ns** | **7.8113 ns** | **0.4282 ns** | **-** | 52 | | ReadOnlyCollection | O(N) | Int32 | 1000 | False | 42.841 ns | 2.3381 ns | 0.1282 ns | - | 53 | | List | O(N) | Int32 | 1000 | False | 42.976 ns | 8.8244 ns | 0.4837 ns | - | 54 | | ImmutableArray | O(N) | Int32 | 1000 | False | 68.369 ns | 6.3947 ns | 0.3505 ns | - | 55 | | | | | | | | | | | 56 | | **Array** | **O(N)** | **Int32** | **1000** | **True** | **28.672 ns** | **3.1231 ns** | **0.1712 ns** | **-** | 57 | | List | O(N) | Int32 | 1000 | True | 29.101 ns | 8.8553 ns | 0.4854 ns | - | 58 | | ImmutableArray | O(N) | Int32 | 1000 | True | 30.060 ns | 1.7139 ns | 0.0939 ns | - | 59 | | ReadOnlyCollection | O(N) | Int32 | 1000 | True | 32.001 ns | 3.3766 ns | 0.1851 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.TryGetValueBenchmark_String_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |--------- |------- |-------- |-------------:|------------:|-----------:|----------:| 15 | | **FrozenDictionary** | **O(1)** | **String** | **1000** | **False** | **4.421 ns** | **0.5035 ns** | **0.0276 ns** | **-** | 16 | | FrozenSet | O(1) | String | 1000 | False | 6.279 ns | 0.4430 ns | 0.0243 ns | - | 17 | | Dictionary | O(1) | String | 1000 | False | 7.095 ns | 1.3972 ns | 0.0766 ns | - | 18 | | HashSet | O(1) | String | 1000 | False | 7.151 ns | 1.3768 ns | 0.0755 ns | - | 19 | | ReadOnlyDictionary | O(1) | String | 1000 | False | 9.358 ns | 1.8240 ns | 0.1000 ns | - | 20 | | ImmutableHashSet | O(1) | String | 1000 | False | 15.515 ns | 3.4441 ns | 0.1888 ns | - | 21 | | ImmutableDictionary | O(1) | String | 1000 | False | 16.466 ns | 8.5353 ns | 0.4678 ns | - | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **String** | **1000** | **True** | **4.857 ns** | **0.6566 ns** | **0.0360 ns** | **-** | 24 | | Dictionary | O(1) | String | 1000 | True | 8.973 ns | 1.2395 ns | 0.0679 ns | - | 25 | | HashSet | O(1) | String | 1000 | True | 9.021 ns | 0.4231 ns | 0.0232 ns | - | 26 | | FrozenSet | O(1) | String | 1000 | True | 10.957 ns | 1.4986 ns | 0.0821 ns | - | 27 | | ReadOnlyDictionary | O(1) | String | 1000 | True | 11.229 ns | 1.0306 ns | 0.0565 ns | - | 28 | | ImmutableHashSet | O(1) | String | 1000 | True | 19.697 ns | 2.6280 ns | 0.1441 ns | - | 29 | | ImmutableDictionary | O(1) | String | 1000 | True | 20.911 ns | 5.6117 ns | 0.3076 ns | - | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **String** | **1000** | **False** | **303.085 ns** | **43.5154 ns** | **2.3852 ns** | **-** | 32 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 311.216 ns | 25.6718 ns | 1.4072 ns | - | 33 | | SortedList | O(log(N)) | String | 1000 | False | 319.730 ns | 13.0537 ns | 0.7155 ns | - | 34 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 321.109 ns | 146.2676 ns | 8.0174 ns | - | 35 | | ImmutableSortedDictionary | O(log(N)) | String | 1000 | False | 323.934 ns | 91.7163 ns | 5.0273 ns | - | 36 | | ImmutableSortedSet | O(log(N)) | String | 1000 | False | 336.183 ns | 32.8334 ns | 1.7997 ns | - | 37 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 353.234 ns | 88.7693 ns | 4.8657 ns | - | 38 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | False | 357.601 ns | 75.3227 ns | 4.1287 ns | - | 39 | | SortedDictionary | O(log(N)) | String | 1000 | False | 358.193 ns | 15.9219 ns | 0.8727 ns | - | 40 | | | | | | | | | | | 41 | | **ImmutableSortedDictionary** | **O(log(N))** | **String** | **1000** | **True** | **237.537 ns** | **45.9291 ns** | **2.5175 ns** | **-** | 42 | | ImmutableSortedSet | O(log(N)) | String | 1000 | True | 245.379 ns | 55.6813 ns | 3.0521 ns | - | 43 | | 'List (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 264.359 ns | 52.4840 ns | 2.8768 ns | - | 44 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 264.543 ns | 23.6696 ns | 1.2974 ns | - | 45 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 265.289 ns | 36.0121 ns | 1.9739 ns | - | 46 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | String | 1000 | True | 268.966 ns | 10.2658 ns | 0.5627 ns | - | 47 | | SortedList | O(log(N)) | String | 1000 | True | 270.004 ns | 52.1485 ns | 2.8584 ns | - | 48 | | SortedDictionary | O(log(N)) | String | 1000 | True | 281.324 ns | 66.7073 ns | 3.6565 ns | - | 49 | | SortedSet | O(log(N)) | String | 1000 | True | 289.570 ns | 59.6427 ns | 3.2692 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **False** | **3,005.547 ns** | **436.2414 ns** | **23.9119 ns** | **-** | 52 | | ImmutableArray | O(N) | String | 1000 | False | 3,938.770 ns | 526.2674 ns | 28.8465 ns | - | 53 | | List | O(N) | String | 1000 | False | 4,002.468 ns | 646.8517 ns | 35.4561 ns | - | 54 | | Array | O(N) | String | 1000 | False | 4,006.808 ns | 218.9723 ns | 12.0026 ns | - | 55 | | | | | | | | | | | 56 | | **ReadOnlyCollection** | **O(N)** | **String** | **1000** | **True** | **1,435.280 ns** | **715.1145 ns** | **39.1978 ns** | **-** | 57 | | ImmutableArray | O(N) | String | 1000 | True | 1,789.514 ns | 753.6574 ns | 41.3105 ns | - | 58 | | List | O(N) | String | 1000 | True | 1,826.351 ns | 227.0355 ns | 12.4446 ns | - | 59 | | Array | O(N) | String | 1000 | True | 1,831.162 ns | 403.4804 ns | 22.1161 ns | - | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/Benchmarks.TryGetValueBenchmark_StructInts_-report-github.md: -------------------------------------------------------------------------------- 1 | ``` 2 | 3 | BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3) 4 | AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores 5 | .NET SDK 8.0.101 6 | [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 7 | ShortRun : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 8 | 9 | Job=ShortRun IterationCount=3 LaunchCount=1 10 | WarmupCount=3 11 | 12 | ``` 13 | | Method | Categories | DataType | Length | Existed | Mean | Error | StdDev | Allocated | 14 | |----------------------------------------- |----------- |----------- |------- |-------- |-------------:|--------------:|-----------:|----------:| 15 | | **Dictionary** | **O(1)** | **StructInts** | **1000** | **False** | **19.37 ns** | **4.722 ns** | **0.259 ns** | **32 B** | 16 | | FrozenDictionary | O(1) | StructInts | 1000 | False | 19.79 ns | 7.674 ns | 0.421 ns | 32 B | 17 | | FrozenSet | O(1) | StructInts | 1000 | False | 20.44 ns | 3.003 ns | 0.165 ns | 32 B | 18 | | HashSet | O(1) | StructInts | 1000 | False | 22.08 ns | 0.575 ns | 0.031 ns | 32 B | 19 | | ImmutableDictionary | O(1) | StructInts | 1000 | False | 26.32 ns | 5.736 ns | 0.314 ns | 32 B | 20 | | ImmutableHashSet | O(1) | StructInts | 1000 | False | 27.27 ns | 5.036 ns | 0.276 ns | 32 B | 21 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | False | 33.32 ns | 8.021 ns | 0.440 ns | 32 B | 22 | | | | | | | | | | | 23 | | **FrozenDictionary** | **O(1)** | **StructInts** | **1000** | **True** | **34.89 ns** | **4.106 ns** | **0.225 ns** | **96 B** | 24 | | Dictionary | O(1) | StructInts | 1000 | True | 35.81 ns | 5.208 ns | 0.285 ns | 96 B | 25 | | HashSet | O(1) | StructInts | 1000 | True | 36.13 ns | 21.056 ns | 1.154 ns | 96 B | 26 | | ReadOnlyDictionary | O(1) | StructInts | 1000 | True | 39.45 ns | 20.077 ns | 1.101 ns | 96 B | 27 | | ImmutableHashSet | O(1) | StructInts | 1000 | True | 39.89 ns | 15.302 ns | 0.839 ns | 96 B | 28 | | ImmutableDictionary | O(1) | StructInts | 1000 | True | 40.20 ns | 20.036 ns | 1.098 ns | 96 B | 29 | | FrozenSet | O(1) | StructInts | 1000 | True | 45.59 ns | 18.131 ns | 0.994 ns | 96 B | 30 | | | | | | | | | | | 31 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **False** | **12.72 ns** | **5.499 ns** | **0.301 ns** | **-** | 32 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.01 ns | 1.381 ns | 0.076 ns | - | 33 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.09 ns | 1.804 ns | 0.099 ns | - | 34 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 19.36 ns | 7.034 ns | 0.386 ns | - | 35 | | SortedList | O(log(N)) | StructInts | 1000 | False | 23.61 ns | 1.590 ns | 0.087 ns | 32 B | 36 | | SortedDictionary | O(log(N)) | StructInts | 1000 | False | 27.48 ns | 2.739 ns | 0.150 ns | 32 B | 37 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | False | 36.04 ns | 9.127 ns | 0.500 ns | - | 38 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | False | 36.35 ns | 0.942 ns | 0.052 ns | - | 39 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | False | 36.37 ns | 3.093 ns | 0.170 ns | - | 40 | | | | | | | | | | | 41 | | **SortedSet** | **O(log(N))** | **StructInts** | **1000** | **True** | **18.54 ns** | **3.569 ns** | **0.196 ns** | **-** | 42 | | 'ImmutableArray (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.32 ns | 1.372 ns | 0.075 ns | - | 43 | | 'Array (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.34 ns | 5.513 ns | 0.302 ns | - | 44 | | 'List (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 20.60 ns | 2.491 ns | 0.137 ns | - | 45 | | SortedList | O(log(N)) | StructInts | 1000 | True | 26.04 ns | 0.961 ns | 0.053 ns | 32 B | 46 | | ImmutableSortedDictionary | O(log(N)) | StructInts | 1000 | True | 26.37 ns | 6.991 ns | 0.383 ns | - | 47 | | SortedDictionary | O(log(N)) | StructInts | 1000 | True | 27.64 ns | 4.194 ns | 0.230 ns | 32 B | 48 | | ImmutableSortedSet | O(log(N)) | StructInts | 1000 | True | 29.35 ns | 2.403 ns | 0.132 ns | - | 49 | | 'ImmutableList (Sorted + BinarySearch)' | O(log(N)) | StructInts | 1000 | True | 31.13 ns | 6.216 ns | 0.341 ns | - | 50 | | | | | | | | | | | 51 | | **ReadOnlyCollection** | **O(N)** | **StructInts** | **1000** | **False** | **12,254.54 ns** | **12,885.831 ns** | **706.316 ns** | **64000 B** | 52 | | Array | O(N) | StructInts | 1000 | False | 12,541.77 ns | 16,640.837 ns | 912.140 ns | 64000 B | 53 | | List | O(N) | StructInts | 1000 | False | 12,764.38 ns | 10,572.542 ns | 579.517 ns | 64000 B | 54 | | ImmutableArray | O(N) | StructInts | 1000 | False | 12,889.71 ns | 12,221.754 ns | 669.916 ns | 64000 B | 55 | | | | | | | | | | | 56 | | **List** | **O(N)** | **StructInts** | **1000** | **True** | **6,091.29 ns** | **5,640.174 ns** | **309.157 ns** | **30901 B** | 57 | | ReadOnlyCollection | O(N) | StructInts | 1000 | True | 6,179.42 ns | 5,716.694 ns | 313.351 ns | 30901 B | 58 | | Array | O(N) | StructInts | 1000 | True | 6,261.18 ns | 7,441.955 ns | 407.919 ns | 30901 B | 59 | | ImmutableArray | O(N) | StructInts | 1000 | True | 6,350.76 ns | 8,862.417 ns | 485.779 ns | 30901 B | 60 | -------------------------------------------------------------------------------- /BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/rich-html-files.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/BenchmarkDotNet.Artifacts/results (v2-length-1K-with-bigO)/rich-html-files.zip -------------------------------------------------------------------------------- /Benchmarks/Base/CustomConfig.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Configs; 2 | using BenchmarkDotNet.Order; 3 | using BenchmarkDotNet.Reports; 4 | using BenchmarkDotNet.Running; 5 | using System.Collections.Immutable; 6 | 7 | public class CustomConfig : ManualConfig 8 | { 9 | public CustomConfig() 10 | { 11 | Orderer = new CustomOerderer(); 12 | SummaryStyle = DefaultConfig.Instance.SummaryStyle.WithMaxParameterColumnWidth(50); 13 | } 14 | 15 | private class CustomOerderer : IOrderer 16 | { 17 | public IEnumerable GetExecutionOrder(ImmutableArray benchmarksCase, IEnumerable order = null) 18 | => benchmarksCase; 19 | 20 | public IEnumerable GetSummaryOrder(ImmutableArray benchmarksCases, Summary summary) 21 | => from benchmarkCase in benchmarksCases 22 | orderby 23 | string.Join('_', benchmarkCase.Descriptor.Categories), 24 | benchmarkCase.Parameters["Length"]?.ToString() ?? "", 25 | benchmarkCase.Parameters["Sorted"]?.ToString() ?? "", 26 | benchmarkCase.Parameters["Existed"]?.ToString() ?? "", 27 | summary[benchmarkCase]?.ResultStatistics?.Mean ?? 0 28 | select benchmarkCase; 29 | 30 | public string GetHighlightGroupKey(BenchmarkCase benchmarkCase) 31 | => string.Join('_', string.Join('_', benchmarkCase.Descriptor.Categories), benchmarkCase.Parameters["Length"], benchmarkCase.Parameters["Sorted"], benchmarkCase.Parameters["Existed"]); 32 | 33 | public string GetLogicalGroupKey(ImmutableArray allBenchmarksCases, BenchmarkCase benchmarkCase) 34 | => string.Join('_', string.Join('_', benchmarkCase.Descriptor.Categories), benchmarkCase.Parameters["Length"], benchmarkCase.Parameters["Sorted"], benchmarkCase.Parameters["Existed"]); 35 | 36 | public IEnumerable> GetLogicalGroupOrder(IEnumerable> logicalGroups, IEnumerable order = null) 37 | => logicalGroups.OrderBy(it => it.Key); 38 | 39 | public bool SeparateLogicalGroups => true; 40 | } 41 | } -------------------------------------------------------------------------------- /Benchmarks/InitializeBenchmark.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using BenchmarkDotNetVisualizer; 3 | using System.Collections.Frozen; 4 | using System.Collections.Immutable; 5 | using System.Collections.ObjectModel; 6 | using System.ComponentModel.DataAnnotations; 7 | using Utilities; 8 | 9 | namespace Benchmarks; 10 | 11 | [RichHtmlExporter( 12 | title: "Benchmark of Collection Initializing", 13 | groupByColumns: ["Length", "Sorted"], 14 | sortByColumns: ["Mean", "Allocated"], 15 | spectrumColumns: ["Mean", "Allocated"], 16 | highlightGroups: true, 17 | dividerMode: RenderTableDividerMode.SeparateTables, 18 | htmlWrapMode: HtmlDocumentWrapMode.RichDataTables)] 19 | [GenericTypeArguments(typeof(int))] 20 | [GenericTypeArguments(typeof(string))] 21 | [GenericTypeArguments(typeof(StructInts))] 22 | [GenericTypeArguments(typeof(StructStrings))] 23 | [GenericTypeArguments(typeof(ClassInts))] 24 | [GenericTypeArguments(typeof(ClassStrings))] 25 | [GenericTypeArguments(typeof(RecordStructInts))] 26 | [GenericTypeArguments(typeof(RecordStructStrings))] 27 | [GenericTypeArguments(typeof(RecordClassInts))] 28 | [GenericTypeArguments(typeof(RecordClassStrings))] 29 | [Display(Name = "Benchmark of Collection Initializing for '{0}' type", GroupName = "Benchmark of Collection Initializing")] 30 | public class InitializeBenchmark : BenchmarkBase 31 | { 32 | public string[] GetDataTypeName { get; } = [typeof(T).Name]; 33 | 34 | [ParamsSource(nameof(GetDataTypeName), Priority = -1)] 35 | public string DataType { get; set; } 36 | 37 | [Params(10_000, 1_000_000)] 38 | public int Length { get; set; } 39 | 40 | [ParamsAllValues] 41 | public bool Sorted { get; set; } 42 | 43 | private T[] _array; 44 | 45 | [GlobalSetup] 46 | public void Setup() 47 | { 48 | var arr = GetRandomUniqueArray(Length); 49 | _array = Sorted ? arr.Sort() : arr; 50 | } 51 | 52 | [Benchmark] 53 | public T[] Array() 54 | { 55 | return _array.ToArray(); 56 | } 57 | 58 | [Benchmark(Description = "Array (Sorted)")] 59 | public T[] Array_Sorted() 60 | { 61 | return _array.ToArray().Sort(); 62 | } 63 | 64 | [Benchmark] 65 | public ImmutableArray ImmutableArray() 66 | { 67 | return _array.ToImmutableArray(); 68 | } 69 | 70 | [Benchmark(Description = "ImmutableArray (Sorted)")] 71 | public ImmutableArray ImmutableArray_Sorted() 72 | { 73 | return _array.ToImmutableArray().Sort(); 74 | } 75 | 76 | [Benchmark] 77 | public List List() 78 | { 79 | return _array.ToList(); 80 | } 81 | 82 | [Benchmark(Description = "List (Sorted)")] 83 | public List List_Sorted() 84 | { 85 | var list = _array.ToList(); 86 | list.Sort(); 87 | return list; 88 | } 89 | 90 | [Benchmark] 91 | public ImmutableList ImmutableList() 92 | { 93 | return _array.ToImmutableList(); 94 | } 95 | 96 | [Benchmark(Description = "ImmutableList (Sorted)")] 97 | public ImmutableList ImmutableList_Sorted() 98 | { 99 | return _array.ToImmutableList().Sort(); 100 | } 101 | 102 | [Benchmark] 103 | public LinkedList LinkedList() 104 | { 105 | return _array.ToLinkedList(); 106 | } 107 | 108 | [Benchmark] 109 | public ReadOnlyCollection ReadOnlyCollection() 110 | { 111 | return _array.ToReadOnlyCollection(); 112 | } 113 | 114 | [Benchmark] 115 | public HashSet HashSet() 116 | { 117 | return _array.ToHashSet(); 118 | } 119 | 120 | [Benchmark] 121 | public ImmutableHashSet ImmutableHashSet() 122 | { 123 | return _array.ToImmutableHashSet(); 124 | } 125 | 126 | [Benchmark] 127 | public SortedSet SortedSet() 128 | { 129 | return _array.ToSortedSet(); 130 | } 131 | 132 | [Benchmark] 133 | public ImmutableSortedSet ImmutableSortedSet() 134 | { 135 | return _array.ToImmutableSortedSet(); 136 | } 137 | 138 | [Benchmark] 139 | public Dictionary Dictionary() 140 | { 141 | return _array.ToDictionary(); 142 | } 143 | 144 | [Benchmark] 145 | public ReadOnlyDictionary ReadOnlyDictionary() 146 | { 147 | return _array.ToReadOnlyDictionary(); 148 | } 149 | 150 | [Benchmark] 151 | public SortedDictionary SortedDictionary() 152 | { 153 | return _array.ToSortedDictionary(); 154 | } 155 | 156 | [Benchmark] 157 | public SortedList SortedList() 158 | { 159 | return _array.ToSortedList(); 160 | } 161 | 162 | [Benchmark] 163 | public ImmutableDictionary ImmutableDictionary() 164 | { 165 | return _array.ToImmutableDictionary(); 166 | } 167 | 168 | [Benchmark] 169 | public ImmutableSortedDictionary ImmutableSortedDictionary() 170 | { 171 | return _array.ToImmutableSortedDictionary(); 172 | } 173 | 174 | [Benchmark] 175 | public FrozenSet FrozenSet() 176 | { 177 | return _array.ToFrozenSet(); 178 | } 179 | 180 | [Benchmark] 181 | public FrozenDictionary FrozenDictionary() 182 | { 183 | return _array.ToFrozenDictionary(); 184 | } 185 | } -------------------------------------------------------------------------------- /DataTypes/ClassInts.cs: -------------------------------------------------------------------------------- 1 | public class ClassInts : 2 | IEquatable, 3 | IComparable 4 | { 5 | public int Prop1 { get; set; } 6 | public int Prop2 { get; set; } 7 | public int Prop3 { get; set; } 8 | 9 | public override int GetHashCode() 10 | { 11 | // unchecked only needed if you're compiling with arithmetic checks enabled 12 | // (the default compiler behaviour is *disabled*, so most folks won't need this) 13 | unchecked // Overflow is fine, just wrap 14 | { 15 | var hash = 13 /*17*/; 16 | hash = (hash * 7 /*23*/) + Prop1.GetHashCode(); 17 | hash = (hash * 7 /*23*/) + Prop2.GetHashCode(); 18 | hash = (hash * 7 /*23*/) + Prop3.GetHashCode(); 19 | return hash; 20 | } 21 | } 22 | 23 | public bool Equals(ClassInts other) 24 | { 25 | if (other is null) 26 | return false; 27 | 28 | return Prop1 == other.Prop1 && Prop2 == other.Prop2 && Prop3 == other.Prop3; 29 | } 30 | 31 | public int CompareTo(ClassInts other) 32 | { 33 | if (other is null) 34 | return 1; 35 | 36 | var result = Prop1.CompareTo(other.Prop1); 37 | if (result == 0) 38 | { 39 | result = Prop2.CompareTo(other.Prop2); 40 | if (result == 0) 41 | result = Prop3.CompareTo(other.Prop3); 42 | } 43 | return result; 44 | } 45 | } -------------------------------------------------------------------------------- /DataTypes/ClassStrings.cs: -------------------------------------------------------------------------------- 1 | public class ClassStrings : 2 | IEquatable, 3 | IComparable 4 | { 5 | public string Prop1 { get; set; } 6 | public string Prop2 { get; set; } 7 | public string Prop3 { get; set; } 8 | 9 | public override int GetHashCode() 10 | { 11 | // unchecked only needed if you're compiling with arithmetic checks enabled 12 | // (the default compiler behaviour is *disabled*, so most folks won't need this) 13 | unchecked // Overflow is fine, just wrap 14 | { 15 | var hash = 13 /*17*/; 16 | hash = (hash * 7 /*23*/) + (Prop1?.GetHashCode() ?? 0); 17 | hash = (hash * 7 /*23*/) + (Prop2?.GetHashCode() ?? 0); 18 | hash = (hash * 7 /*23*/) + (Prop3?.GetHashCode() ?? 0); 19 | return hash; 20 | } 21 | } 22 | 23 | public bool Equals(ClassStrings other) 24 | { 25 | if (other is null) 26 | return false; 27 | 28 | return Prop1 == other.Prop1 && Prop2 == other.Prop2 && Prop3 == other.Prop3; 29 | } 30 | 31 | public int CompareTo(ClassStrings other) 32 | { 33 | if (other is null) 34 | return 1; 35 | 36 | var result = Prop1.CompareTo(other.Prop1); 37 | if (result == 0) 38 | { 39 | result = Prop2.CompareTo(other.Prop2); 40 | if (result == 0) 41 | result = Prop3.CompareTo(other.Prop3); 42 | } 43 | return result; 44 | } 45 | } -------------------------------------------------------------------------------- /DataTypes/RecordClassInts.cs: -------------------------------------------------------------------------------- 1 | public record RecordClassInts(int Prop1, int Prop2, int Prop3) : 2 | IComparable 3 | { 4 | public int CompareTo(RecordClassInts other) 5 | { 6 | if (other is null) 7 | return 1; 8 | 9 | var result = Prop1.CompareTo(other.Prop1); 10 | if (result == 0) 11 | { 12 | result = Prop2.CompareTo(other.Prop2); 13 | if (result == 0) 14 | result = Prop3.CompareTo(other.Prop3); 15 | } 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DataTypes/RecordClassStrings.cs: -------------------------------------------------------------------------------- 1 | public record RecordClassStrings(string Prop1, string Prop2, string Prop3) : 2 | IComparable 3 | { 4 | public int CompareTo(RecordClassStrings other) 5 | { 6 | if (other is null) 7 | return 1; 8 | 9 | var result = Prop1.CompareTo(other.Prop1); 10 | if (result == 0) 11 | { 12 | result = Prop2.CompareTo(other.Prop2); 13 | if (result == 0) 14 | result = Prop3.CompareTo(other.Prop3); 15 | } 16 | return result; 17 | } 18 | } -------------------------------------------------------------------------------- /DataTypes/RecordStructInts.cs: -------------------------------------------------------------------------------- 1 | public record struct RecordStructInts(int Prop1, int Prop2, int Prop3) : IComparable 2 | { 3 | public int CompareTo(RecordStructInts other) 4 | { 5 | var result = Prop1.CompareTo(other.Prop1); 6 | if (result == 0) 7 | { 8 | result = Prop2.CompareTo(other.Prop2); 9 | if (result == 0) 10 | result = Prop3.CompareTo(other.Prop3); 11 | } 12 | return result; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataTypes/RecordStructStrings.cs: -------------------------------------------------------------------------------- 1 | public record struct RecordStructStrings(string Prop1, string Prop2, string Prop3) : IComparable 2 | { 3 | public int CompareTo(RecordStructStrings other) 4 | { 5 | var result = Prop1.CompareTo(other.Prop1); 6 | if (result == 0) 7 | { 8 | result = Prop2.CompareTo(other.Prop2); 9 | if (result == 0) 10 | result = Prop3.CompareTo(other.Prop3); 11 | } 12 | return result; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataTypes/StructInts.cs: -------------------------------------------------------------------------------- 1 | public struct StructInts : IComparable 2 | { 3 | public int Prop1 { get; set; } 4 | public int Prop2 { get; set; } 5 | public int Prop3 { get; set; } 6 | 7 | public int CompareTo(StructInts other) 8 | { 9 | var result = Prop1.CompareTo(other.Prop1); 10 | if (result == 0) 11 | { 12 | result = Prop2.CompareTo(other.Prop2); 13 | if (result == 0) 14 | result = Prop3.CompareTo(other.Prop3); 15 | } 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DataTypes/StructStrings.cs: -------------------------------------------------------------------------------- 1 | public struct StructStrings : IComparable 2 | { 3 | public string Prop1 { get; set; } 4 | public string Prop2 { get; set; } 5 | public string Prop3 { get; set; } 6 | 7 | public int CompareTo(StructStrings other) 8 | { 9 | var result = Prop1.CompareTo(other.Prop1); 10 | if (result == 0) 11 | { 12 | result = Prop2.CompareTo(other.Prop2); 13 | if (result == 0) 14 | result = Prop3.CompareTo(other.Prop3); 15 | } 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DotNet-Collections-Benchmark.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | disable 8 | Collection-Search-Benchmark 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DotNet-Collections-Benchmark.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34330.188 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNet-Collections-Benchmark", "DotNet-Collections-Benchmark.csproj", "{542536C3-6A13-4F3A-8195-BF36E89B465B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {542536C3-6A13-4F3A-8195-BF36E89B465B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {542536C3-6A13-4F3A-8195-BF36E89B465B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {542536C3-6A13-4F3A-8195-BF36E89B465B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {542536C3-6A13-4F3A-8195-BF36E89B465B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0AC3374B-0233-4990-B4EC-6FA4A61B4B4C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mohammad Javad Ebrahimi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![.NET Collections Benchmark](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/repository-image.png) 3 | 4 | # .NET Collections Benchmark 5 | 6 | A comprehensive performance comparison benchmark between different .NET collections. 7 | 8 | > If you are working with small collections (e.g. 100 items) or your code is not HOT path (not executed frequently), it's not a big deal and you usually don't need to worry about your collection's performance. (It's better not to waste your time with premature micro-optimizations) 9 | > 10 | > However, if you are dealing with Large collections (e.g. 100K, 1M, or more items) or your code is HOT path (executed frequently), you should be obsessed with performance and choosing the best collection type based on your needs and conditions. 11 | > 12 | > This benchmark report helps you to choose the best collection type in terms of performance based on your needs and conditions. 13 | 14 | ## Give it a Star! ⭐️ 15 | 16 | If you find this repository useful and like it, why not give it a star? if not, never mind! :) 17 | 18 | ## Benchmarks 19 | 20 | - [Benchmark of Collection Searching (Contains method) in terms of Execution Time (Mean)](#benchmark-of-collection-searching-contains-method-in-terms-of-execution-time-mean) 21 | - [Benchmark of Collection Searching (Contains method) in terms of Allocation Size](#benchmark-of-collection-searching-contains-method-in-terms-of-allocation-size) 22 | - [Benchmark of Collection Initializing in terms of Execution Time (Mean)](#benchmark-of-collection-initializing-in-terms-of-execution-time-mean) 23 | - [Benchmark of Collection Initializing in terms of Allocation Size](#benchmark-of-collection-initializing-in-terms-of-allocation-size) 24 | - [Benchmark of Collection Searching (TryGetValue method) in terms of Execution Time (Mean)](#benchmark-of-collection-searching-trygetvalue-method-in-terms-of-execution-time-mean) 25 | - [Benchmark of Collection Searching (TryGetValue method) in terms of Allocation Size](#benchmark-of-collection-searching-trygetvalue-method-in-terms-of-allocation-size) 26 | 27 | ### Benchmark of Collection Searching (Contains method) in terms of Execution Time (Mean) 28 | 29 | - **Visit [HTML Page](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchContains-Mean.html)** 30 | - **Visit [Full Image](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchContains-Mean.png)** 31 | 32 | ![Benchmark-SearchContains-Mean-Preview](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchContains-Mean-Preview.png) 33 | 34 | ### Benchmark of Collection Searching (Contains method) in terms of Allocation Size 35 | 36 | - **Visit [HTML Page](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchContains-Allocated.html)** 37 | - **Visit [Full Image](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchContains-Allocated.png)** 38 | 39 | ![Benchmark-SearchContains-Allocated-Preview](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchContains-Allocated-Preview.png) 40 | 41 | ### Benchmark of Collection Initializing in terms of Execution Time (Mean) 42 | 43 | - **Visit [HTML Page](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-Initialize-Mean.html)** 44 | - **Visit [Full Image](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-Initialize-Mean.png)** 45 | 46 | ![Benchmark-Initialize-Mean-Preview](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-Initialize-Mean-Preview.png) 47 | 48 | ### Benchmark of Collection Initializing in terms of Allocation Size 49 | 50 | - **Visit [HTML Page](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-Initialize-Allocated.html)** 51 | - **Visit [Full Image](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-Initialize-Allocated.png)** 52 | 53 | ![Benchmark-Initialize-Allocated-Preview](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-Initialize-Allocated-Preview.png) 54 | 55 | ### Benchmark of Collection Searching (TryGetValue method) in terms of Execution Time (Mean) 56 | 57 | - **Visit [HTML Page](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchTryGetValue-Mean.html)** 58 | - **Visit [Full Image](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchTryGetValue-Mean.png)** 59 | 60 | ![Benchmark-SearchTryGetValue-Mean-Preview](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchTryGetValue-Mean-Preview.png) 61 | 62 | ### Benchmark of Collection Searching (TryGetValue method) in terms of Allocation Size 63 | 64 | - **Visit [HTML Page](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchTryGetValue-Allocated.html)** 65 | - **Visit [Full Image](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchTryGetValue-Allocated.png)** 66 | 67 | ![Benchmark-SearchTryGetValue-Allocated-Preview](https://mjebrahimi.github.io/DotNet-Collections-Benchmark/Benchmark-SearchTryGetValue-Allocated-Preview.png) 68 | 69 | ## BenchmarkDotNetVisualizer🌈 70 | 71 | All the benchmarks are created by [BenchmarkDotNetVisualizer](https://github.com/mjebrahimi/BenchmarkDotNetVisualizer). 72 | 73 | ## Todo 74 | 75 | - [ ] Add .NET 9.0 **OrderedDictionary** to the benchmarks 76 | - [ ] Add benchmarks for other operations such as **Add**, **Insert**, **Remove**, and **Update**. 77 | 78 | ## Useful Resources 79 | 80 | - [.NET Big-O Algorithm Complexity Cheat Sheet](https://github.com/RehanSaeed/.NET-Big-O-Algorithm-Complexity-Cheat-Sheet) 81 | -------------------------------------------------------------------------------- /Utils/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Buffers; 2 | using System.Collections.Frozen; 3 | using System.Collections.Immutable; 4 | using System.Collections.ObjectModel; 5 | 6 | namespace Utilities; 7 | 8 | public static class CollectionExtensions 9 | { 10 | public static SortedSet ToSortedSet(this IEnumerable collection) 11 | { 12 | return new SortedSet(collection); 13 | } 14 | 15 | public static Dictionary ToDictionary(this IEnumerable collection) where TKey : notnull 16 | { 17 | return collection.ToDictionary(p => p, _ => false); 18 | } 19 | 20 | public static ImmutableDictionary ToImmutableDictionary(this IEnumerable collection) where TKey : notnull 21 | { 22 | return collection.ToImmutableDictionary(p => p, _ => false); 23 | } 24 | 25 | public static ImmutableSortedDictionary ToImmutableSortedDictionary(this IEnumerable collection) where TKey : notnull 26 | { 27 | return collection.ToImmutableSortedDictionary(p => p, _ => false); 28 | } 29 | 30 | public static FrozenDictionary ToFrozenDictionary(this IEnumerable collection) where TKey : notnull 31 | { 32 | return collection.ToFrozenDictionary(p => p, _ => false); 33 | } 34 | 35 | public static SortedDictionary ToSortedDictionary(this IEnumerable collection) where TKey : notnull 36 | { 37 | return new SortedDictionary(collection.ToDictionary()); 38 | } 39 | 40 | public static ReadOnlyDictionary ToReadOnlyDictionary(this IEnumerable collection) where TKey : notnull 41 | { 42 | return new ReadOnlyDictionary(collection.ToDictionary()); 43 | } 44 | 45 | public static SortedList ToSortedList(this IEnumerable collection) where TKey : notnull 46 | { 47 | return new SortedList(collection.ToDictionary()); 48 | } 49 | 50 | public static ReadOnlyCollection ToReadOnlyCollection(this IEnumerable collection) 51 | { 52 | //this idea could be implemented for other collections as well 53 | //ArgumentNullException.ThrowIfNull(collection); 54 | //if ((collection.TryGetNonEnumeratedCount(out var count) && count == 0) || collection.Any() is false) 55 | // return ReadOnlyCollection.Empty; 56 | 57 | return new ReadOnlyCollection(collection.ToArray()); 58 | } 59 | 60 | public static LinkedList ToLinkedList(this IEnumerable collection) 61 | { 62 | return new LinkedList(collection); 63 | } 64 | } -------------------------------------------------------------------------------- /Utils/ImmutableArrayExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | 3 | namespace Utilities; 4 | 5 | public static class ImmutableArrayExtensions 6 | { 7 | public static bool ContainsBinarySearch(this ImmutableArray collection, T item) 8 | { 9 | return collection.BinarySearch(item) >= 0; 10 | } 11 | 12 | public static bool ContainsBinarySearch(this ImmutableArray collection, T item, int index, int length) 13 | { 14 | return collection.BinarySearch(index, length, item, null) >= 0; 15 | } 16 | 17 | public static bool ContainsBinarySearch(this ImmutableArray collection, T item, IComparer comparer) 18 | { 19 | return collection.BinarySearch(item, comparer) >= 0; 20 | } 21 | 22 | public static bool ContainsBinarySearch(this ImmutableArray collection, T item, int index, int length, IComparer comparer) 23 | { 24 | return collection.BinarySearch(index, length, item, comparer) >= 0; 25 | } 26 | 27 | public static bool TryGetValue(this ImmutableArray collection, T value, out T? actualValue) 28 | { 29 | var index = collection.IndexOf(value); 30 | if (index >= 0) 31 | { 32 | actualValue = collection[index]; 33 | return true; 34 | } 35 | 36 | actualValue = default; 37 | return false; 38 | } 39 | 40 | public static bool TryGetValueBinarySearch(this ImmutableArray collection, T value, out T? actualValue) 41 | { 42 | var index = collection.BinarySearch(value); 43 | if (index >= 0) 44 | { 45 | actualValue = collection[index]; 46 | return true; 47 | } 48 | 49 | actualValue = default; 50 | return false; 51 | } 52 | } -------------------------------------------------------------------------------- /Utils/ImmutableListExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Immutable; 2 | 3 | namespace Utilities; 4 | 5 | public static class ImmutableListExtensions 6 | { 7 | public static bool ContainsBinarySearch(this ImmutableList collection, T item) 8 | { 9 | return collection.BinarySearch(item) >= 0; 10 | } 11 | 12 | public static bool ContainsBinarySearch(this ImmutableList collection, T item, int index, int length) 13 | { 14 | return collection.BinarySearch(index, length, item, null) >= 0; 15 | } 16 | 17 | public static bool ContainsBinarySearch(this ImmutableList collection, T item, IComparer comparer) 18 | { 19 | return collection.BinarySearch(item, comparer) >= 0; 20 | } 21 | 22 | public static bool ContainsBinarySearch(this ImmutableList collection, T item, int index, int length, IComparer comparer) 23 | { 24 | return collection.BinarySearch(index, length, item, comparer) >= 0; 25 | } 26 | 27 | public static bool TryGetValue(this ImmutableList collection, T value, out T? actualValue) 28 | { 29 | var index = collection.IndexOf(value); 30 | if (index >= 0) 31 | { 32 | actualValue = collection[index]; 33 | return true; 34 | } 35 | 36 | actualValue = default; 37 | return false; 38 | } 39 | 40 | public static bool TryGetValueBinarySearch(this ImmutableList collection, T value, out T? actualValue) 41 | { 42 | var index = collection.BinarySearch(value); 43 | if (index >= 0) 44 | { 45 | actualValue = collection[index]; 46 | return true; 47 | } 48 | 49 | actualValue = default; 50 | return false; 51 | } 52 | } -------------------------------------------------------------------------------- /Utils/ListExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace Utilities; 4 | 5 | public static class ListExtensions 6 | { 7 | public static bool ContainsBinarySearch(this List collection, T item) 8 | { 9 | return collection.BinarySearch(item) >= 0; 10 | } 11 | 12 | public static bool ContainsBinarySearch(this List collection, T item, int index, int length) 13 | { 14 | return collection.BinarySearch(index, length, item, null) >= 0; 15 | } 16 | 17 | public static bool ContainsBinarySearch(this List collection, T item, IComparer comparer) 18 | { 19 | return collection.BinarySearch(item, comparer) >= 0; 20 | } 21 | 22 | public static bool ContainsBinarySearch(this List collection, T item, int index, int length, IComparer comparer) 23 | { 24 | return collection.BinarySearch(index, length, item, comparer) >= 0; 25 | } 26 | 27 | public static bool TryGetValue(this List collection, T value, out T? actualValue) 28 | { 29 | var index = collection.IndexOf(value); 30 | if (index >= 0) 31 | { 32 | actualValue = collection[index]; 33 | return true; 34 | } 35 | 36 | actualValue = default; 37 | return false; 38 | } 39 | 40 | public static bool TryGetValueBinarySearch(this List collection, T value, out T? actualValue) 41 | { 42 | var index = collection.BinarySearch(value); 43 | if (index >= 0) 44 | { 45 | actualValue = collection[index]; 46 | return true; 47 | } 48 | 49 | actualValue = default; 50 | return false; 51 | } 52 | 53 | #region ReadOnlyCollection and LinkedList 54 | public static bool TryGetValue(this ReadOnlyCollection collection, T value, out T? actualValue) 55 | { 56 | var index = collection.IndexOf(value); 57 | if (index >= 0) 58 | { 59 | actualValue = collection[index]; 60 | return true; 61 | } 62 | 63 | actualValue = default; 64 | return false; 65 | } 66 | 67 | public static bool TryGetValue(this LinkedList collection, T value, out T? actualValue) 68 | { 69 | var node = collection.Find(value); 70 | if (node is not null) 71 | { 72 | actualValue = node.Value; 73 | return true; 74 | } 75 | 76 | actualValue = default; 77 | return false; 78 | } 79 | #endregion 80 | } -------------------------------------------------------------------------------- /docs/Benchmark-Initialize-Allocated-Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-Initialize-Allocated-Preview.png -------------------------------------------------------------------------------- /docs/Benchmark-Initialize-Allocated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-Initialize-Allocated.png -------------------------------------------------------------------------------- /docs/Benchmark-Initialize-Allocated.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-Initialize-Allocated.webp -------------------------------------------------------------------------------- /docs/Benchmark-Initialize-Mean-Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-Initialize-Mean-Preview.png -------------------------------------------------------------------------------- /docs/Benchmark-Initialize-Mean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-Initialize-Mean.png -------------------------------------------------------------------------------- /docs/Benchmark-Initialize-Mean.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-Initialize-Mean.webp -------------------------------------------------------------------------------- /docs/Benchmark-SearchContains-Allocated-Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchContains-Allocated-Preview.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchContains-Allocated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchContains-Allocated.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchContains-Allocated.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchContains-Allocated.webp -------------------------------------------------------------------------------- /docs/Benchmark-SearchContains-Mean-Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchContains-Mean-Preview.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchContains-Mean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchContains-Mean.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchContains-Mean.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchContains-Mean.webp -------------------------------------------------------------------------------- /docs/Benchmark-SearchTryGetValue-Allocated-Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchTryGetValue-Allocated-Preview.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchTryGetValue-Allocated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchTryGetValue-Allocated.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchTryGetValue-Allocated.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchTryGetValue-Allocated.webp -------------------------------------------------------------------------------- /docs/Benchmark-SearchTryGetValue-Mean-Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchTryGetValue-Mean-Preview.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchTryGetValue-Mean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchTryGetValue-Mean.png -------------------------------------------------------------------------------- /docs/Benchmark-SearchTryGetValue-Mean.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/Benchmark-SearchTryGetValue-Mean.webp -------------------------------------------------------------------------------- /docs/assets/cshtml-razor.min.js: -------------------------------------------------------------------------------- 1 | hljs.registerLanguage("cshtml-razor",(()=>{"use strict";return n=>{ 2 | var e="built_in",s={},a={begin:"}",className:e,endsParent:!0},i={begin:"{", 3 | end:"}",contains:[n.QUOTE_STRING_MODE,"self"]},r=n.COMMENT("@\\*","\\*@",{ 4 | relevance:10}),g={begin:"@[A-Za-z0-9\\._:-]+",returnBegin:!0, 5 | end:"(\\r|\\n|<|\\s|\"|')",subLanguage:"csharp",contains:[{begin:"@",className:e 6 | },{begin:"\\[",end:"\\]",skip:!0},{begin:"\\(",end:"\\)",skip:!0}],returnEnd:!0 7 | },t={begin:"[@]{0,1}",returnBegin:!0,end:"",returnEnd:!0, 8 | subLanguage:"cshtml-razor",contains:[{begin:"[@]{0,1}",className:e},{ 9 | begin:"",className:e,endsParent:!0}]},c={begin:"@\\(",end:"\\)", 10 | returnBegin:!0,returnEnd:!0,subLanguage:"csharp",contains:[{begin:"@\\(", 11 | className:e},{begin:"\\(",end:"\\)",subLanguage:"csharp", 12 | contains:[n.QUOTE_STRING_MODE,"self",t]},t,{begin:"\\)",className:e, 13 | endsParent:!0}]},b=((n,e)=>{var s={endsWithParent:!0,illegal:/`]+/}]}]}]} 17 | ;return[{className:"meta",begin:"",relevance:10,contains:[{ 18 | begin:"\\[",end:"\\]"}]},n.COMMENT("\x3c!--","--\x3e",{relevance:10}),{ 19 | begin:"<\\!\\[CDATA\\[",end:"\\]\\]>",relevance:10},{className:"meta", 20 | begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag", 21 | begin:"|$)",end:">",keywords:{name:"style"},contains:[s],starts:{ 22 | end:"",returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag", 23 | begin:"|$)",end:">",keywords:{name:"script"},contains:[s], 24 | starts:{end:"<\/script>",returnEnd:!0, 25 | subLanguage:["actionscript","javascript","handlebars","xml"]}},{className:"tag", 26 | begin:"",contains:[{className:"name",begin:/[^\/><\s]+/,relevance:0 27 | },s]}].concat(e) 28 | })(n,[g,c]),l="^\\s*@(page|model|using|inherits|inject|layout)",u={ 29 | begin:l+"[^\\r\\n{\\(]*$",end:"$",returnBegin:!0,returnEnd:!0,contains:[{ 30 | begin:l,className:e},{variants:[{begin:"\\r|\\n",endsParent:!0},{ 31 | begin:"\\s[^\\r\\n]+",end:"$"},{begin:"$"}],className:"type",endsParent:!0}] 32 | },d={variants:[{begin:"@\\{",end:"}"},{begin:"@code\\s*\\{",end:"}"}], 33 | returnBegin:!0,returnEnd:!0,subLanguage:"csharp",contains:[{ 34 | begin:"@(code\\s*)?\\{",className:e},s,{begin:"{",end:"}",contains:["self"], 35 | skip:!0},a]},o={begin:"^\\s*@helper[\\s]*[^{]+[\\s]*{",returnBegin:!0, 36 | returnEnd:!0,end:"}",subLanguage:"cshtml-razor",contains:[{begin:"@helper", 37 | className:e},{begin:"{",className:e},a]},m=[{begin:"@for[\\s]*\\([^{]+[\\s]*{", 38 | end:"}"},{begin:"@if[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 39 | begin:"@switch[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 40 | begin:"@while[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 41 | begin:"@using[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 42 | begin:"@lock[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 43 | begin:"@foreach[\\s]*\\([^{]+[\\s]*{",end:"}"}],N={variants:m,returnBegin:!0, 44 | returnEnd:!0,subLanguage:"csharp",contains:[{variants:m.map((n=>({begin:n.begin 45 | }))),returnBegin:!0,contains:[{begin:"@",className:e},{variants:m.map((n=>({ 46 | begin:n.begin.substr(1,n.begin.length-2)}))),subLanguage:"csharp"},{begin:"{", 47 | className:e}]},s,{variants:[{begin:"}[\\s]*else\\sif[\\s]*\\([^{]+[\\s]*{"},{ 48 | begin:"}[\\s]*else[\\s]*{"}],returnBegin:!0,contains:[{begin:"}",className:e},{ 49 | variants:[{begin:"[\\s]*else\\sif[\\s]*\\([^{]+[\\s]*{"},{ 50 | begin:"[\\s]*else[\\s]*"}],subLanguage:"csharp"},{begin:"{",className:e}]},i,a] 51 | },h={begin:"@try[\\s]*{",end:"}",returnBegin:!0,returnEnd:!0, 52 | subLanguage:"csharp",contains:[{begin:"@",className:e},{begin:"try[\\s]*{", 53 | subLanguage:"csharp"},{variants:[{begin:"}[\\s]*catch[\\s]*\\([^\\)]+\\)[\\s]*{" 54 | },{begin:"}[\\s]*finally[\\s]*{"}],returnBegin:!0,contains:[{begin:"}", 55 | className:e},{variants:[{begin:"[\\s]*catch[\\s]*\\([^\\)]+\\)[\\s]*"},{ 56 | begin:"[\\s]*finally[\\s]*"}],subLanguage:"csharp"},{begin:"{",className:e}] 57 | },s,i,a]},p="@section[\\s]+[a-zA-Z0-9]+[\\s]*{",v=[u,o,d,N,{begin:p, 58 | returnBegin:!0,returnEnd:!0,end:"}",subLanguage:"cshtml-razor",contains:[{ 59 | begin:p,className:e},i,a]},{begin:"@await ",returnBegin:!0,subLanguage:"csharp", 60 | end:"(\\r|\\n|<|\\s)",contains:[{begin:"@await ",className:e},{ 61 | begin:"[<\\r\\n]",endsParent:!0}]},h,{variants:[{begin:"@@"},{begin:"[a-zA-Z]+@" 62 | }],skip:!0},t,r,c,{className:"meta",begin:"",relevance:10, 63 | contains:[{begin:"\\[",end:"\\]"}]},{begin:"<\\!\\[CDATA\\[",end:"\\]\\]>", 64 | relevance:10}].concat(b);return[d,N,h].forEach((n=>{ 65 | var e=v.filter((e=>e!==n)),a=n.contains.indexOf(s) 66 | ;n.contains.splice.apply(n.contains,[a,1].concat(e))})),{ 67 | aliases:["cshtml","razor","razor-cshtml","cshtml-razor"],contains:v}}})()); -------------------------------------------------------------------------------- /docs/assets/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | 73 | code{ 74 | background-color: whitesmoke !important; 75 | padding: 3px; 76 | } -------------------------------------------------------------------------------- /docs/cshtml-razor.min.js: -------------------------------------------------------------------------------- 1 | hljs.registerLanguage("cshtml-razor",(()=>{"use strict";return n=>{ 2 | var e="built_in",s={},a={begin:"}",className:e,endsParent:!0},i={begin:"{", 3 | end:"}",contains:[n.QUOTE_STRING_MODE,"self"]},r=n.COMMENT("@\\*","\\*@",{ 4 | relevance:10}),g={begin:"@[A-Za-z0-9\\._:-]+",returnBegin:!0, 5 | end:"(\\r|\\n|<|\\s|\"|')",subLanguage:"csharp",contains:[{begin:"@",className:e 6 | },{begin:"\\[",end:"\\]",skip:!0},{begin:"\\(",end:"\\)",skip:!0}],returnEnd:!0 7 | },t={begin:"[@]{0,1}",returnBegin:!0,end:"",returnEnd:!0, 8 | subLanguage:"cshtml-razor",contains:[{begin:"[@]{0,1}",className:e},{ 9 | begin:"",className:e,endsParent:!0}]},c={begin:"@\\(",end:"\\)", 10 | returnBegin:!0,returnEnd:!0,subLanguage:"csharp",contains:[{begin:"@\\(", 11 | className:e},{begin:"\\(",end:"\\)",subLanguage:"csharp", 12 | contains:[n.QUOTE_STRING_MODE,"self",t]},t,{begin:"\\)",className:e, 13 | endsParent:!0}]},b=((n,e)=>{var s={endsWithParent:!0,illegal:/`]+/}]}]}]} 17 | ;return[{className:"meta",begin:"",relevance:10,contains:[{ 18 | begin:"\\[",end:"\\]"}]},n.COMMENT("\x3c!--","--\x3e",{relevance:10}),{ 19 | begin:"<\\!\\[CDATA\\[",end:"\\]\\]>",relevance:10},{className:"meta", 20 | begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag", 21 | begin:"|$)",end:">",keywords:{name:"style"},contains:[s],starts:{ 22 | end:"",returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag", 23 | begin:"|$)",end:">",keywords:{name:"script"},contains:[s], 24 | starts:{end:"<\/script>",returnEnd:!0, 25 | subLanguage:["actionscript","javascript","handlebars","xml"]}},{className:"tag", 26 | begin:"",contains:[{className:"name",begin:/[^\/><\s]+/,relevance:0 27 | },s]}].concat(e) 28 | })(n,[g,c]),l="^\\s*@(page|model|using|inherits|inject|layout)",u={ 29 | begin:l+"[^\\r\\n{\\(]*$",end:"$",returnBegin:!0,returnEnd:!0,contains:[{ 30 | begin:l,className:e},{variants:[{begin:"\\r|\\n",endsParent:!0},{ 31 | begin:"\\s[^\\r\\n]+",end:"$"},{begin:"$"}],className:"type",endsParent:!0}] 32 | },d={variants:[{begin:"@\\{",end:"}"},{begin:"@code\\s*\\{",end:"}"}], 33 | returnBegin:!0,returnEnd:!0,subLanguage:"csharp",contains:[{ 34 | begin:"@(code\\s*)?\\{",className:e},s,{begin:"{",end:"}",contains:["self"], 35 | skip:!0},a]},o={begin:"^\\s*@helper[\\s]*[^{]+[\\s]*{",returnBegin:!0, 36 | returnEnd:!0,end:"}",subLanguage:"cshtml-razor",contains:[{begin:"@helper", 37 | className:e},{begin:"{",className:e},a]},m=[{begin:"@for[\\s]*\\([^{]+[\\s]*{", 38 | end:"}"},{begin:"@if[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 39 | begin:"@switch[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 40 | begin:"@while[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 41 | begin:"@using[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 42 | begin:"@lock[\\s]*\\([^{]+[\\s]*{",end:"}"},{ 43 | begin:"@foreach[\\s]*\\([^{]+[\\s]*{",end:"}"}],N={variants:m,returnBegin:!0, 44 | returnEnd:!0,subLanguage:"csharp",contains:[{variants:m.map((n=>({begin:n.begin 45 | }))),returnBegin:!0,contains:[{begin:"@",className:e},{variants:m.map((n=>({ 46 | begin:n.begin.substr(1,n.begin.length-2)}))),subLanguage:"csharp"},{begin:"{", 47 | className:e}]},s,{variants:[{begin:"}[\\s]*else\\sif[\\s]*\\([^{]+[\\s]*{"},{ 48 | begin:"}[\\s]*else[\\s]*{"}],returnBegin:!0,contains:[{begin:"}",className:e},{ 49 | variants:[{begin:"[\\s]*else\\sif[\\s]*\\([^{]+[\\s]*{"},{ 50 | begin:"[\\s]*else[\\s]*"}],subLanguage:"csharp"},{begin:"{",className:e}]},i,a] 51 | },h={begin:"@try[\\s]*{",end:"}",returnBegin:!0,returnEnd:!0, 52 | subLanguage:"csharp",contains:[{begin:"@",className:e},{begin:"try[\\s]*{", 53 | subLanguage:"csharp"},{variants:[{begin:"}[\\s]*catch[\\s]*\\([^\\)]+\\)[\\s]*{" 54 | },{begin:"}[\\s]*finally[\\s]*{"}],returnBegin:!0,contains:[{begin:"}", 55 | className:e},{variants:[{begin:"[\\s]*catch[\\s]*\\([^\\)]+\\)[\\s]*"},{ 56 | begin:"[\\s]*finally[\\s]*"}],subLanguage:"csharp"},{begin:"{",className:e}] 57 | },s,i,a]},p="@section[\\s]+[a-zA-Z0-9]+[\\s]*{",v=[u,o,d,N,{begin:p, 58 | returnBegin:!0,returnEnd:!0,end:"}",subLanguage:"cshtml-razor",contains:[{ 59 | begin:p,className:e},i,a]},{begin:"@await ",returnBegin:!0,subLanguage:"csharp", 60 | end:"(\\r|\\n|<|\\s)",contains:[{begin:"@await ",className:e},{ 61 | begin:"[<\\r\\n]",endsParent:!0}]},h,{variants:[{begin:"@@"},{begin:"[a-zA-Z]+@" 62 | }],skip:!0},t,r,c,{className:"meta",begin:"",relevance:10, 63 | contains:[{begin:"\\[",end:"\\]"}]},{begin:"<\\!\\[CDATA\\[",end:"\\]\\]>", 64 | relevance:10}].concat(b);return[d,N,h].forEach((n=>{ 65 | var e=v.filter((e=>e!==n)),a=n.contains.indexOf(s) 66 | ;n.contains.splice.apply(n.contains,[a,1].concat(e))})),{ 67 | aliases:["cshtml","razor","razor-cshtml","cshtml-razor"],contains:v}}})()); -------------------------------------------------------------------------------- /docs/repository-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjebrahimi/DotNet-Collections-Benchmark/cc2927504fffe8ab13875b8116cba0c739c4fa10/docs/repository-image.png --------------------------------------------------------------------------------