Skip to content

codebeltnet/benchmarkdotnet

Extensions for BenchmarkDotNet API by Codebelt

Extensions for BenchmarkDotNet API by Codebelt

BenchmarkDotNet CI/CD Pipelinecodecov Quality Gate Status Maintainability Rating Reliability Rating Security Rating OpenSSF Scorecard

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.

Concept

The Extensions for BenchmarkDotNet API by Codebelt is designed to bring clarity, structure, and consistency to BenchmarkDotNet projects.

Folder Structure

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 a test folder typically contains *.Tests projects,
  • 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.

Layout Example

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

Codebelt.Extensions.BenchmarkDotNet.Console Example

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));
            });
        });
    }
}

📚 Documentation

Full documentation (generated by DocFx) located here: https://benchmarkdotnet.codebelt.net/

📦 Standalone Packages

Provides a focused API for BenchmarkDotNet projects.

Package vNext Stable Downloads
Codebelt.Extensions.BenchmarkDotNet vNext Stable Downloads
Codebelt.Extensions.BenchmarkDotNet.Console vNext Stable Downloads

Contributing to Extensions for BenchmarkDotNet API by Codebelt

Contributions are welcome and appreciated.

Feel free to submit issues, feature requests, or pull requests to help improve this library.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This library provides a uniform way of benchmarking your projects with BenchmarkDotNet.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published