This repository contains a collection of C# benchmarks to compare the performance of different approaches to solve the same problem.
- List.TrimExess() Benchmark
- for vs foreach vs ForEach() Benchmark
- Reflection/Class vs NonReflection/Struct Benchmark
- Normal flow vs Throw Exception Benchmark
- String Replace Benchmark
- Ctor Instantiate vs Lazy Instantiaten
- Prometheus-net metrics Benchmark
- PropertyGetter Benchmark
- Reverse string Benchmark
- Concat string Benchmark
- Word reverse Benchmark
- OrderBy.First/Last vs Min/Max Benchmark
- Collection Shuffle Benchmark
- FileStream Write vs WriteAsync Benchmark
- Stream Read Bytes Benchmark
- Stream Write Bytes Benchmark
- Stream Read String Benchmark
- Array Allocating Benchmark
- Array Resizing Benchmark
- String StartWith Benchmark
- GetHashCode and Equals Benchmark
- Enumerable NullOrEmpty Benchmark
- .NET Collections Benchmark⭐️
- Converting Enum To String Benchmark
- Array Copy Benchmark
- String Find First Duplicate Char Benchmark
- Convert Number To Base62 String Benchmark
- MediatR vs Mediator vs SlimMediator Benchmark
- AggressiveInlining Benchmark
- New Instantiate Benchmark
Some ideas for future benchmarks:
- SearchValues vs Regex and other Alternatives
- UnsafeAccessor vs Reflection-Based Access
- Source Generated Regex vs Regular Regex (in various manner: static, instance, compiled, ...)
Create an issue or discussion if you found a Mistake or have a Suggestion.
Or if you want to add more benchmarks to this project:
- Fork it
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request