Introduction to NBench
Cross-platform performance benchmarking and testing framework for .NET applications.
NBench is designed for .NET developers who need to care about performance and want the ability to "unit test" their application's performance just like XUnit or NUnit tests their application code.
Why NBench?
NBench was originally developed to help support the Akka.NET project to measure the performance of each code change to its critical areas. NBench is generally used for measuring the performance of entire feature areas, not micro-benchmarking the fastest way to unroll a for
loop or whether it's more efficient to have an array of struct
s or a struct
of arrays.
You can see more about the origins of NBench from our talk at .NET Fringe: Introducing NBench - Automated Performance Testing and Benchmarking for .NET:
Frequently Asked Questions
Who Should Use NBench?
NBench is designed to support the following types of cases:
- Macro-level benchmarks to test the throughput, memory, and Garbage Collection (GC) performance of entire features;
- Writing XUnit-style assertions to validate that observed performance never falls below an acceptable limit; or
- Benchmarking the performance asynchonrous and concurrent code.
If you have any one of these cases, then NBench is for you.
Does NBench Support .NET Core / .NET Framework Version {x}?
Given that NBench users are often on the edge of performance, NBench doesn't ship with any kind of external runner as of NBench 2.0. Instead, NBench is delivered as a .NET Standard 2.0 - so it can be used in any version of .NET Framework 4.6.1 or higher and any version of .NET Core 2.0 or higher.
Users install NBench into a stand-alone Console Application and run that application to generate their benchmarks. To learn more, see NBench Quickstart Tutorial.
What sorts of things can NBench help me measure?
NBench is highly extensible, but out of the box we support assertions and benchmarking measurements for:
- Throughput;
- Memory utilization;
- Total elapsed runtime; and
- Garbage collection.
You can learn more by reading the Measurements and Assertions page.
How can I get started with NBench?
Please see our NBench Quickstart Tutorial.