A powerful .NET library for transforming methods into benchmarks, tracking performance, and sharing reproducible measurement experiments.
BenchmarkDotNet is a powerful .NET library designed for benchmarking code performance. It transforms methods into benchmarks, automates the measurement process, and provides reliable, statistically sound results. The library solves the problem of manual, error-prone performance testing by handling complexities like warm-up iterations, steady-state detection, and multi-environment comparisons automatically.
.NET developers, library authors, and performance engineers who need to measure and optimize the performance of their C#, F#, or Visual Basic code across different runtimes and environments.
Developers choose BenchmarkDotNet because it offers a simple, declarative API similar to unit testing, while providing professional-grade statistical analysis and automation. Its unique selling point is the combination of ease of use with high reliability, protecting users from common benchmarking mistakes and delivering detailed, actionable insights.
Powerful .NET library for benchmarking
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses simple attributes like `[Benchmark]` and `[Params]` to write benchmarks similarly to unit tests, making it accessible without deep performance expertise, as shown in the example code.
Incorporates perfolizer and pragmastat engines to handle pilot experiments, warm-up iterations, and steady-state detection automatically, ensuring high measurement precision and warning about pitfalls.
Supports benchmarking across various runtimes (.NET Framework, .NET Core, Mono, NativeAOT), operating systems, and architectures with simple job configurations, demonstrated in the multi-runtime example.
Can measure managed and native memory traffic and provide disassembly listings for deep performance analysis, going beyond simple timing metrics.
The automated processes for warm-up, iterations, and statistical calculations introduce substantial time overhead, making it inefficient for very short-running methods or rapid iteration.
Configuring custom jobs, environments, or diagnostics beyond basic attributes requires using the fluent API or manual setup, which can be daunting and error-prone for non-experts.
Exclusively designed for .NET runtimes (C#, F#, VB); cannot benchmark non-.NET code or integrate with polyglot projects, limiting its scope in mixed-technology environments.