Features
These pages cover advanced capabilities that apply across the usage modes. They are opt-in features for experienced benchmarkers who need finer control over measurement, filtering, isolation, or runtime environments.
Categories
Tag benchmarks with [BenchmarkCategory] and include or exclude groups from a run via CLI flags or the programmatic WithCategoryFilter API.
Parameterized benchmarks: Suite mode
Run a benchmark body across multiple input values using WithParameter and typed Add lambdas. Each parameter combination produces a separate benchmark entry.
Parameterized benchmarks: Harness mode
Run a benchmark body across multiple input values using the [BenchmarkCase] and [BenchmarkCases] attributes. Includes a comparison with the suite-mode API.
Isolated runs
Run Suite and Harness benchmarks in clean child processes when runtime state contamination matters more than raw execution speed. Harness mode is isolated by default; suites opt in with WithIsolation().
Multi-runtime comparison
Run the same benchmarks across multiple .NET runtimes (net8.0, net9.0, net10.0) and compare results side-by-side. Available in Suite mode (WithRuntimes), Harness mode (--runtimes CLI flag), and Harness mode via the [Runtimes] attribute.
Multiple launches
Run each benchmark N times as independent launches to measure run-to-run variance and produce cross-launch aggregation statistics.
Environment control
Pin benchmarks to CPU cores, raise process priority, and detect noisy hosts to reduce measurement noise at its source. Opt-in controls that complement the statistical noise handling.
Dependency injection
Use Microsoft.Extensions.DependencyInjection (or any container that exposes an IServiceProvider) to give benchmark classes constructor dependencies. Harness mode only.
State isolation
Keep InstanceLifetime.PerClass statistically valid with IStateReset or automatic per-benchmark isolation fallback when shared state would contaminate timing.
See also
- Usage modes - the four ways to run benchmarks
- Output - reporters and output control
- Configuration - configuration and CLI flags
