This project benchmarks and compares the performance of various .NET 9 collection types and demonstrates new C# features related to collections in the latest version.
- List<T>: Standard dynamic array.
- HashSet<T>: Unordered set for fast lookups.
- Dictionary<TKey,TValue>: Key-value mapping.
- Span<T> and Memory<T>: For high-performance memory access (planned/extendable).
- KeyValuePair<TKey,TValue>: Used in dictionary enumeration.
- New C# 12/13 features: Including collection expressions, and LINQ methods like
FirstOrDefault
,LastOrDefault
, etc.
- Build the project in Release mode for accurate benchmarks:
dotnet build -c Release
- Run the benchmarks:
dotnet run -c Release
When you run the benchmarks, BenchmarkDotNet generates a folder called BenchmarkDotNet.Artifacts
in the project directory. This folder contains:
- Benchmark results: Detailed reports in Markdown, CSV, and log formats.
- Generated code: Auto-generated code used for running the benchmarks.
- Build outputs: Compiled binaries for each benchmark run.
- Logs: Diagnostic and execution logs for troubleshooting.
You can review the results in the BenchmarkDotNet.Artifacts/results
subfolder. These files help you analyze and compare the performance of different collections and features.
Note: The
BenchmarkDotNet.Artifacts
folder can be safely deleted at any time; it will be regenerated on the next benchmark run.
- Add new benchmarks for additional collections or C# features in
Program.cs
. - Follow the project's coding standards: use clear and descriptive names, and document each benchmark.
- See
.github/copilot-instructions.md
for workspace-specific guidance.
- .NET 9 SDK
For more details, see the source code