BenchmarkDotNet: turning a method into a measurement you can defend
Powerful .NET library for benchmarking
At a glance
- What is it?
- The .NET library that writes, runs and statistically cleans up your microbenchmarks, adopted by the runtime, Roslyn and 27,000 other repositories.
- Who is it for?
- BenchmarkDotNet is the reference answer to microbenchmarking in .NET, and its value is less about speed than about honesty: it runs the benchmarks on all the runtimes you ask for, performs warm-up iterations, aggregates the measurements, and prints an error column next to every mean so a reader can see whether a difference is real. The attribute surface is covered in depth on benchmarkdotnet.org under features and guides.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly C#, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 21, 2026, and from our analysis. They are not legal advice.
Star history
- dotnet/BenchmarkDotNet11,531 ★ · +25
| Repository | 2026-10-07 | 2026-11-21 |
|---|---|---|
| dotnet/BenchmarkDotNet | 11.5k | 11.5k |
25 Stars in the last 45 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Writing a benchmark looks like writing a test
The pitch in the README is that BenchmarkDotNet is no harder than writing unit tests, and the example proves it. You mark a class with attributes describing which runtimes to try, mark fields with the values to parameterize over, add a setup method, and mark the methods under test.
[SimpleJob(RuntimeMoniker.Net472, baseline: true)]
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
[SimpleJob(RuntimeMoniker.NativeAot70)]
[SimpleJob(RuntimeMoniker.Mono)]
[RPlotExporter]
public class Md5VsSha256
{
private SHA256 sha256 = SHA256.Create();
private MD5 md5 = MD5.Create();
private byte[] data;
[Params(1000, 10000)]
public int N;
[GlobalSetup]
public void Setup()
{
data = new byte[N];
new Random(42).NextBytes(data);
}
[Benchmark]
public byte[] Sha256() => sha256.ComputeHash(data);
[Benchmark]
public byte[] Md5() => md5.ComputeHash(data);
}Two details matter more than they look. `[Params(1000, 10000)]` makes the framework run the whole benchmark once per value with N set accordingly and `[GlobalSetup]` marks the setup method that fills the data array.
The project lives at dotnet/BenchmarkDotNet, is MIT licensed, has around 11,500 stars and 1,081 forks, and was last pushed on 2026-11-01.
What the library automates before it prints a number
The README organizes its feature list under four headings, and automation is the biggest one. The README describes the boilerplate it takes over: a pilot experiment to pick the number of invocations, warm-up iterations until a steady state, main iterations with basic statistics, and checks for dead code elimination, loop unrolling effects, multimodality and outliers.
Reliability comes from the statistics rather than from repetition alone. The results table has a Mean column and next to it an Error and a StdDev column, and the README credits the perfolizer and pragmastat statistical engine for reliable and precise results. A difference of two percent with an error of five percent is not a difference, and the table is formatted so you can see that without doing arithmetic yourself.
The framework also inspects the design. The README says it warns you if something is wrong with your benchmark design or obtained measurements.
Reading the summary table the tool prints
The README shows the output for the MD5 versus SHA256 example, and the shape of that table is the shape of every BenchmarkDotNet result.
| Method | Runtime | N | Mean | Error | StdDev | Ratio |
|------- |-------------- |------ |-----------:|----------:|----------:|------:|
| Sha256 | .NET 4.7.2 | 1000 | 7.735 us | 0.1913 us | 0.4034 us | 1.00 |
| Sha256 | .NET Core 3.0 | 1000 | 3.989 us | 0.0796 us | 0.0745 us | 0.50 |
| Sha256 | NativeAOT 7.0 | 1000 | 4.091 us | 0.0811 us | 0.1562 us | 0.53 |
| Sha256 | Mono | 1000 | 13.117 us | 0.2485 us | 0.5019 us | 1.70 |Seven columns carry the meaning. Method is what you wrote, Runtime is which job produced the row, N is the parameter value, Mean is the central estimate with Error and StdDev describing the uncertainty and spread, and Ratio is the comparison against the baseline method, which is why one method is marked `baseline: true`.
Results export to Markdown, HTML, CSV, XML and JSON, and `[RPlotExporter]` adds an R plotting script for charts.
Runtimes, languages and architectures it will run on
The support matrix in the README is long and worth reading literally, because it defines what a job attribute can ask for. Supported runtimes are .NET 5 and later, .NET Framework 4.6.1 and later, .NET Core 2.0 and later, Mono, and NativeAOT. Supported languages are C#, F# and Visual Basic, so this is not a C#-only tool despite the sample being C#.
Operating systems covered are Windows, Linux and macOS. Architectures listed are x86, x64, ARM, ARM64, Wasm and LoongArch64.
Trimming the job list is the normal first act of adapting the example to your own code.
Compile-time analyzers arrived in 0.15.7
The GitHub releases listed are v0.15.8 (2025-11-30), v0.16.0-preview.1 (2026-09-22) and v0.16.0-preview.2 (2026-09-23). The release notes for these versions are not part of the README, so check the releases page and the documentation site for what changed in each.
Where the README ends and the documentation site starts
The README is a good advertisement. It makes the adoption claim, shows one complete example, shows the table that example produces, lists the support matrix, and then opens the feature section with four headings.
Everything else is on benchmarkdotnet.org, linked from the top navigation bar: a getting started guide with a copy-pasteable version of the example, an overview document, and per-feature pages. The parameterization and baseline pages are linked directly from the feature prose, which tells you where the interesting material lives.
Adoption is the other thing worth taking from the README. It claims use in 27,400 or more GitHub projects and names the .NET Runtime, the Roslyn compiler and the dotnet/performance repository as adopters.
Editorial conclusion
BenchmarkDotNet is the reference answer to microbenchmarking in .NET, and its value is less about speed than about honesty: it runs the benchmarks on all the runtimes you ask for, performs warm-up iterations, aggregates the measurements, and prints an error column next to every mean so a reader can see whether a difference is real. The attribute surface is covered in depth on benchmarkdotnet.org under features and guides. Start with the MD5 versus SHA256 example from the README, delete the runtime attributes you do not need, and read the getting started guide before trusting a single ratio.
Frequently asked questions
How do I use BenchmarkDotNet?
Create a class with methods marked `[Benchmark]`, add attributes such as `[SimpleJob]` for the runtimes to test and `[Params]` to parameterize over input sizes, then follow the getting started guide to run it. BenchmarkDotNet runs the benchmarks on all the runtimes, warms the code up, aggregates the measurements and prints a table with mean, error, standard deviation and a ratio against the baseline.
Does BenchmarkDotNet work with Mono and NativeAOT as well as CoreCLR?
Yes. The README lists supported runtimes as .NET 5+, .NET Framework 4.6.1+, .NET Core 2.0+, Mono and NativeAOT, across Windows, Linux and macOS. You select them with attributes such as `[SimpleJob(RuntimeMoniker.Mono)]`.
Can I export BenchmarkDotNet results for Prometheus?
The README says results can be exported to md, html, csv, xml, json and other formats; check the documentation site for Prometheus or OpenMetrics support. Charts are also available, and the README example adds chart output with the `[RPlotExporter]` attribute rather than through a separate command.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/dotnet-benchmarkdotnet)Star history chart for your README
[](https://hysenlabs.com/projects/dotnet-benchmarkdotnet)Was this useful?