An open API service indexing awesome lists of open source software.

https://github.com/codebeltnet/benchmarkdotnet

This library provides a uniform way of benchmarking your projects with BenchmarkDotNet.
https://github.com/codebeltnet/benchmarkdotnet

Last synced: 4 months ago
JSON representation

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

Awesome Lists containing this project

README

          

![Extensions for BenchmarkDotNet API by Codebelt](.nuget/Codebelt.Extensions.BenchmarkDotNet/icon.png)

# Extensions for BenchmarkDotNet API by Codebelt

[![BenchmarkDotNet CI/CD Pipeline](https://github.com/codebeltnet/benchmarkdotnet/actions/workflows/ci-pipeline.yml/badge.svg)](https://github.com/codebeltnet/benchmarkdotnet/actions/workflows/ci-pipeline.yml)[![codecov](https://codecov.io/gh/codebeltnet/benchmarkdotnet/graph/badge.svg?token=qX3lHGvFS4)](https://codecov.io/gh/codebeltnet/benchmarkdotnet) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=benchmarkdotnet&metric=alert_status)](https://sonarcloud.io/dashboard?id=benchmarkdotnet) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=benchmarkdotnet&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=benchmarkdotnet) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=benchmarkdotnet&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=benchmarkdotnet) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=benchmarkdotnet&metric=security_rating)](https://sonarcloud.io/dashboard?id=benchmarkdotnet) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/codebeltnet/benchmarkdotnet/badge)](https://scorecard.dev/viewer/?uri=github.com/codebeltnet/benchmarkdotnet)

An open-source project (MIT license) that targets and complements the [BenchmarkDotNet](https://github.com/dotnet/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

```text
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.

```csharp
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](https://github.com/dotnet/docfx)) located here: https://benchmarkdotnet.codebelt.net/

## 📦 Standalone Packages

Provides a focused API for BenchmarkDotNet projects.

|Package|vNext|Stable|Downloads|
|:--|:-:|:-:|:-:|
| [Codebelt.Extensions.BenchmarkDotNet](https://www.nuget.org/packages/Codebelt.Extensions.BenchmarkDotNet/) | ![vNext](https://img.shields.io/nuget/vpre/Codebelt.Extensions.BenchmarkDotNet?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Codebelt.Extensions.BenchmarkDotNet?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Codebelt.Extensions.BenchmarkDotNet?color=blueviolet&logo=nuget) |
| [Codebelt.Extensions.BenchmarkDotNet.Console](https://www.nuget.org/packages/Codebelt.Extensions.BenchmarkDotNet.Console/) | ![vNext](https://img.shields.io/nuget/vpre/Codebelt.Extensions.BenchmarkDotNet.Console?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Codebelt.Extensions.BenchmarkDotNet.Console?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Codebelt.Extensions.BenchmarkDotNet.Console?color=blueviolet&logo=nuget) |

### Contributing to `Extensions for BenchmarkDotNet API by Codebelt`
[Contributions](.github/CONTRIBUTING.md) 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](LICENSE.md) file for details.