BenchmarkWorkspace Class
Definition
- Namespace
- Codebelt.Extensions.BenchmarkDotNet
- Assemblies
- Codebelt.Extensions.BenchmarkDotNet.dll
Provides a default implementation of IBenchmarkWorkspace for discovering and handling assemblies and their generated artifacts in BenchmarkDotNet.
public sealed class BenchmarkWorkspace : IBenchmarkWorkspace
- Inheritance
-
BenchmarkWorkspace
- Implements
Examples
The following example builds a default BenchmarkWorkspace against the current repository and walks through the two phases the workspace actually performs: discovering every *.Benchmarks.dll under the configured tuning folder for the current build configuration and target framework moniker, then moving the per-run results directory into the long-lived tuning directory once the benchmark run finishes.
using System;
using System.IO;
using Codebelt.Extensions.BenchmarkDotNet;
namespace MyBenchmarks;
public static class Program
{
public static void Main()
{
var repositoryPath = Directory.GetCurrentDirectory();
var options = new BenchmarkWorkspaceOptions
{
RepositoryPath = repositoryPath,
TargetFrameworkMoniker = "net10.0"
};
var workspace = new BenchmarkWorkspace(options);
// Discovers and loads every *.Benchmarks.dll that matches
// <RepositoryPath>/<RepositoryTuningFolder>/bin/<Debug|Release>/<TargetFrameworkMoniker>.
var assemblies = workspace.LoadBenchmarkAssemblies();
Console.WriteLine($"Loaded {assemblies.Length} benchmark assemblies from {repositoryPath}.");
// After a benchmark run, PostProcessArtifacts moves the per-run results directory
// into the configured tuning folder and removes the now-empty results directory.
workspace.PostProcessArtifacts();
}
}
Constructors
| Name | Description |
|---|---|
| BenchmarkWorkspace(BenchmarkWorkspaceOptions) | Initializes a new instance of the BenchmarkWorkspace class with the specified options. |
Methods
| Name | Description |
|---|---|
| GetReportsResultsPath(BenchmarkWorkspaceOptions) | Gets the path to the BenchmarkDotNet results directory |
| GetReportsTuningPath(BenchmarkWorkspaceOptions) | Gets the path to the tuning folder where final benchmark reports are stored. |
| LoadBenchmarkAssemblies() | Loads benchmark assemblies discovered recursively in the tuning folder. |
| PostProcessArtifacts() | Performs post-processing of artifacts produced by BenchmarkDotNet. |