Skip to content

Latest commit

 

History

History
80 lines (48 loc) · 5.18 KB

README.md

File metadata and controls

80 lines (48 loc) · 5.18 KB

.NET Collections Benchmark

.NET Collections Benchmark

A comprehensive performance comparison benchmark between different .NET collections.

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)

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.

This benchmark report helps you to choose the best collection type in terms of performance based on your needs and conditions.

Give it a Star! ⭐️

If you find this repository useful and like it, why not give it a star? if not, never mind! :)

Benchmarks

Benchmark of Collection Searching (Contains method) in terms of Execution Time (Mean)

Benchmark-SearchContains-Mean-Preview

Benchmark of Collection Searching (Contains method) in terms of Allocation Size

Benchmark-SearchContains-Allocated-Preview

Benchmark of Collection Initializing in terms of Execution Time (Mean)

Benchmark-Initialize-Mean-Preview

Benchmark of Collection Initializing in terms of Allocation Size

Benchmark-Initialize-Allocated-Preview

Benchmark of Collection Searching (TryGetValue method) in terms of Execution Time (Mean)

Benchmark-SearchTryGetValue-Mean-Preview

Benchmark of Collection Searching (TryGetValue method) in terms of Allocation Size

Benchmark-SearchTryGetValue-Allocated-Preview

BenchmarkDotNetVisualizer🌈

All the benchmarks are created by BenchmarkDotNetVisualizer.

Todo

  • Add .NET 9.0 OrderedDictionary to the benchmarks
  • Add benchmarks for other operations such as Add, Insert, Remove, and Update.

Useful Resources