An open-source project (MIT license) that targets and complements the BenchmarkDotNet performance library. It provides a uniform and convenient way of doing benchmarking for all project types in .NET.
Your versatile BenchmarkDotNet companion for modern development with .NET 9 and .NET 10.
It is, by heart, free, flexible and built to extend and boost your agile codebelt.
The Extensions for BenchmarkDotNet API by Codebelt is designed to bring clarity, structure, and consistency to BenchmarkDotNet projects.
The folder structure promoted by Codebelt.Extensions.BenchmarkDotNet follows the same architectural principles commonly used for test projects—while remaining purpose-built for benchmarking.
At the solution level, benchmarks are treated as a first-class concern, clearly separated from tooling and output artifacts.
- tuning contains all benchmark projects (e.g.
*.Benchmarks), in the same way that atestfolder typically contains*.Testsprojects, - tooling hosts the executable console application responsible for discovering and running benchmarks,
- reports captures benchmark results and generated artifacts, separated from source code and tooling concerns.
This separation enforces a clean boundary between benchmark definition, execution, and output, making benchmark suites easier to scale, automate, and reason about.
Repository Root
│
├─ reports
│ └─ tuning
│ └─ github
│ └─ MyLibrary.ExampleBenchmarks-report-github.md
│
├─ src
│ └─ MyLibrary
│
├─ test
│ └─ MyLibrary.Tests
│ └─ ExampleTest.cs
│
├─ tooling
│ └─ benchmark-runner
│ └─ Program.cs
│
└─ tuning
└─ MyLibrary.Benchmarks
└─ ExampleBenchmark.cs
Benchmarks are executed through a console-hosted Generic Host, allowing full participation in dependency injection, configuration, logging and more.
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using Codebelt.Extensions.BenchmarkDotNet.Console;
public class Program
{
public static void Main(string[] args)
{
BenchmarkProgram.Run(args, o =>
{
o.AllowDebugBuild = BenchmarkProgram.IsDebugBuild;
o.ConfigureBenchmarkDotNet(c =>
{
var slimJob = BenchmarkWorkspaceOptions.Slim;
return c.AddJob(slimJob.WithRuntime(CoreRuntime.Core90))
.AddJob(slimJob.WithRuntime(CoreRuntime.Core10_0));
});
});
}
}Full documentation (generated by DocFx) located here: https://benchmarkdotnet.codebelt.net/
Provides a focused API for BenchmarkDotNet projects.
| Package | vNext | Stable | Downloads |
|---|---|---|---|
| Codebelt.Extensions.BenchmarkDotNet | |||
| Codebelt.Extensions.BenchmarkDotNet.Console |
Contributions are welcome and appreciated.
Feel free to submit issues, feature requests, or pull requests to help improve this library.
This project is licensed under the MIT License - see the LICENSE file for details.