Table of Contents

Class BenchmarkWorkspace

Namespace
Codebelt.Extensions.BenchmarkDotNet
Assembly
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

Constructors

BenchmarkWorkspace(BenchmarkWorkspaceOptions)

Initializes a new instance of the BenchmarkWorkspace class with the specified options.

public BenchmarkWorkspace(BenchmarkWorkspaceOptions options)

Parameters

options BenchmarkWorkspaceOptions

The BenchmarkWorkspaceOptions which configures repository paths, build modes and BenchmarkDotNet configuration.

Exceptions

ArgumentNullException

options cannot be null.

ArgumentException

options are not in a valid state.

Methods

GetReportsResultsPath(BenchmarkWorkspaceOptions)

Gets the path to the BenchmarkDotNet results directory

public static string GetReportsResultsPath(BenchmarkWorkspaceOptions options)

Parameters

options BenchmarkWorkspaceOptions

The BenchmarkWorkspaceOptions which configures repository paths, build modes and BenchmarkDotNet configuration.

Returns

string

A string containing the full path to the 'results' directory within the artifacts path.

Remarks

This path is constructed from the configured BenchmarkDotNet.Configs.IConfig.ArtifactsPath and the "results" subdirectory.

GetReportsTuningPath(BenchmarkWorkspaceOptions)

Gets the path to the tuning folder where final benchmark reports are stored.

public static string GetReportsTuningPath(BenchmarkWorkspaceOptions options)

Parameters

options BenchmarkWorkspaceOptions

The BenchmarkWorkspaceOptions which configures repository paths, build modes and BenchmarkDotNet configuration.

Returns

string

A string representing the full path to the tuning reports directory.

Remarks

This path is constructed from the configured BenchmarkDotNet.Configs.IConfig.ArtifactsPath and the RepositoryTuningFolder.

LoadBenchmarkAssemblies()

Loads benchmark assemblies discovered recursively in the tuning folder.

public Assembly[] LoadBenchmarkAssemblies()

Returns

Assembly[]

An array of Assembly instances representing the loaded benchmark assemblies.

Remarks

Assemblies are selected by matching the configured BenchmarkProjectSuffix, the build configuration (Debug/Release based on AllowDebugBuild), and the target framework moniker (TargetFrameworkMoniker).

Exceptions

InvalidOperationException

Thrown when no matching assemblies could be loaded from the tuning folder. Ensure the tuning folder contains built benchmark assemblies for the configured build configuration and TFM.

PostProcessArtifacts()

Performs post-processing of artifacts produced by BenchmarkDotNet.

public void PostProcessArtifacts()

Remarks

This method moves files found in the BenchmarkDotNet artifacts "results" directory into the tuning folder under the configured artifacts path and then deletes the now-empty "results" directory.