NBenchmark
NBenchmark is a lightweight benchmarking library for .NET. It is designed around three principles:
- Excellent developer experience. Go from nothing to your first measurement in one line of code.
- High performance. No reflection overhead in the measurement loop, accurate timers, proper GC handling.
- Statistically honest output. Confidence intervals, outlier trimming, and a non-parametric significance test are on by default so you know whether a difference is real.
Packages
| Package | Description |
|---|---|
NBenchmark | The zero-dependency core. All measurement, statistics, and file reporters. |
NBenchmark.Console | Adds a rich terminal table and progress display via Spectre.Console. |
NBenchmark.DependencyInjection | Optional integration that lets [Benchmark] classes have constructor dependencies resolved from an IServiceProvider. |
NBenchmark.Analyzers | Roslyn analyzers that catch common configuration errors at compile time. See the Analyzers page for the full diagnostic list. |
Pick a starting point
Not sure where to begin? Start here:
- Installation - add the NuGet packages
- Quick Start - your first benchmark in 60 seconds
- Key Concepts - what warmup, outliers, and the Error column mean
Already comfortable with the basics?
- Guides - detailed walkthroughs for each usage mode
- Dependency Injection - benchmark classes with constructor dependencies
- Configuration - every option explained
- CLI Reference - all command-line flags for
BenchmarkHost - Analyzers - compile-time diagnostics for NBenchmark (NB0001-NB0010)
- Advanced: Statistics - how the numbers are calculated
