
BenchmarkDotNet
A .NET library that turns C# methods into repeatable performance benchmarks.
- Stars
- 11.5k
- Forks
- 1.1k
- Licence
- MIT
- Language
- C#
- Last update
- 5 days ago
- Type
- Library
What it is
BenchmarkDotNet is a C# library for measuring how fast code runs. You mark methods with attributes like [Benchmark], and it handles repeated runs, warm-up, and statistics, then produces summary tables and exports such as md, html, csv, and json. It is used by many .NET projects, including the .NET Runtime and Roslyn, to compare performance changes.
- Compare SHA256 and MD5 hashing speed across runtimes using the example in the README
- Parameterize a benchmark with [Params] to test several input sizes
- Mark one method as a baseline so other results show a ratio against it
- Export results to csv or json for further analysis or charts
Great for
- .NET developers who want to compare two or more implementations of a method
- Developers checking whether a code change made a method faster or slower
- Teams that want benchmark results they can reproduce and share
- Developers comparing performance across several .NET runtimes or Mono
Not ideal for
- People who only need a quick stopwatch timing and not statistical rigor, since the library adds setup and run time
- Non-.NET languages, because the README lists only C#, F#, and Visual Basic
- Benchmarking whole running applications or servers, since the README says it targets console applications
How to get it
- 1
Install with a package manager
You'll need: .NET SDK
Add the NuGet package to a project
dotnet add package BenchmarkDotNet - 2
Run it
- Create a console application project with the .NET SDK
- Add the BenchmarkDotNet package from NuGet
- Write a class with methods marked [Benchmark]
- Call BenchmarkRunner.Run<YourClass>() from Main and run the project in Release mode
- 3
Get the most out of it
- Use [Params] to test several input sizes in one run
- Mark a reference method with Baseline = true so results show ratios
- Use [SimpleJob] attributes or the fluent ManualConfig API to compare runtimes
- Export results to html, csv, or json, and use the RPlotExporter for plots
- Use console arguments to configure runs without changing code
Downloads
Strengths
- Handles warm-up, repeated iterations, and statistics so the user does not have to write them
- Warns about common benchmarking mistakes and flaws in benchmark design, per the README
- Results table and plots are presented clearly and can be exported in several formats
Trade-offs
- Still requires understanding what you are measuring, since results depend on the machine and setup
- Support for some runtimes in the example, such as .NET Framework and Mono, varies by setup and is not uniform
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| BenchmarkDotNet (this) | 11.5k | Library | intermediate | 5 days ago | .NET developers who want to compare two or more implementations of a method |
| Avalonia | 31.7k | Framework | intermediate | 4 days ago | C# developers who already know XAML or WPF |
| CleanArchitecture | 18.5k | Framework | intermediate | 2 months ago | C# developers starting a new ASP.NET Core project who want a structured layout |
| spectre.console | 11.7k | Library | beginner | 11 days ago | C# or .NET developers writing command-line tools |
| Terminal.Gui | 11.3k | Library | intermediate | 6 days ago | C# / .NET developers building terminal tools with forms, tables or menus |
| locust | 28.3k | App | intermediate | 4 days ago | Backend or QA engineers who want load tests kept in version control as normal code |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.