Table of Contents

Class BenchmarkWorkspaceOptions

Namespace
Codebelt.Extensions.BenchmarkDotNet
Assembly
Codebelt.Extensions.BenchmarkDotNet.dll

Configuration options for BenchmarkWorkspace.

public class BenchmarkWorkspaceOptions : IValidatableParameterObject, IPostConfigurableParameterObject, IParameterObject
Inheritance
BenchmarkWorkspaceOptions
Implements
IPostConfigurableParameterObject
Extension Methods

Remarks

The following table shows the initial property values for an instance of BenchmarkWorkspaceOptions.

PropertyInitial Value
RepositoryPathResolved runtime by filesystem, e.g. C:\Repos\MyBenchmarkRepo.
ConfigurationBenchmarkDotNet configured to use recommended settings as outlined in: https://github.com/dotnet/performance/blob/main/src/harness/BenchmarkDotNet.Extensions/RecommendedConfig.cs.
TargetFrameworkMonikerResolved runtime by reflection, e.g. net10.0.
RepositoryTuningFolderDefaultRepositoryTuningFolder
RepositoryReportsFolderDefaultRepositoryReportsFolder
BenchmarkProjectSuffixDefaultBenchmarkProjectSuffix
AllowDebugBuildfalse

Constructors

BenchmarkWorkspaceOptions()

Initializes a new instance of the BenchmarkWorkspaceOptions class with sensible defaults.

public BenchmarkWorkspaceOptions()

Fields

DefaultBenchmarkProjectSuffix

The default suffix used to identify benchmark projects.

public const string DefaultBenchmarkProjectSuffix = "Benchmarks"

Field Value

string

DefaultRepositoryReportsFolder

The default folder name where benchmark reports are written relative to the repository path.

public const string DefaultRepositoryReportsFolder = "reports"

Field Value

string

DefaultRepositoryTuningFolder

The default folder name used for tuning artifacts relative to the repository path.

public const string DefaultRepositoryTuningFolder = "tuning"

Field Value

string

Slim

A tuned BenchmarkDotNet.Jobs.Job preset that serves as a fast, reliable baseline for most benchmarks, balancing measurement accuracy with developer efficiency.

public static readonly Job Slim

Field Value

Job

A BenchmarkDotNet.Jobs.Job configured with reduced warmup, shortened iteration duration, controlled iteration counts, and without system power plan enforcement.

Remarks

Based on the recommended configuration used in the .NET Performance repository: https://github.com/dotnet/performance/blob/main/src/harness/BenchmarkDotNet.Extensions/RecommendedConfig.cs

Properties

AllowDebugBuild

Gets or sets a value indicating whether the benchmarks should be allowed to run using a Debug build.

public bool AllowDebugBuild { get; set; }

Property Value

bool

true to allow Debug builds for benchmarks; otherwise, false. Default is false.

BenchmarkProjectSuffix

Gets or sets the project name suffix used to identify benchmark projects.

public string BenchmarkProjectSuffix { get; set; }

Property Value

string

The benchmark project suffix. Defaults to DefaultBenchmarkProjectSuffix.

Configuration

Gets or sets the BenchmarkDotNet.Configs.IConfig instance used by BenchmarkDotNet.

public IConfig Configuration { get; set; }

Property Value

IConfig

The BenchmarkDotNet configuration.

RepositoryPath

Gets or sets the root path of the repository where benchmark projects and reports live.

public string RepositoryPath { get; set; }

Property Value

string

The repository root path.

RepositoryReportsFolder

Gets or sets the folder name under RepositoryPath used to store generated reports.

public string RepositoryReportsFolder { get; set; }

Property Value

string

The reports folder name. Defaults to DefaultRepositoryReportsFolder.

RepositoryTuningFolder

Gets or sets the folder name under RepositoryPath used to store tuning artifacts.

public string RepositoryTuningFolder { get; set; }

Property Value

string

The tuning folder name. Defaults to DefaultRepositoryTuningFolder.

TargetFrameworkMoniker

Gets or sets the target framework moniker (TFM) string to be used for benchmark discovery and reporting.

public string TargetFrameworkMoniker { get; set; }

Property Value

string

The target framework moniker to run benchmarks for, e.g. net10.0.

Methods

PostConfigureOptions()

Finalizes the configured options before use.

public void PostConfigureOptions()

Remarks

This method updates the Configuration to set the BenchmarkDotNet artifacts path to the combination of RepositoryPath and RepositoryReportsFolder.

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Exceptions

InvalidOperationException

Configuration cannot be null. -or- RepositoryPath cannot be null, empty or consist only of white-space characters. -or- RepositoryTuningFolder cannot be null, empty or consist only of white-space characters. -or- RepositoryReportsFolder cannot be null, empty or consist only of white-space characters. -or- TargetFrameworkMoniker cannot be null, empty or consist only of white-space characters. -or- BenchmarkProjectSuffix cannot be null, empty or consist only of white-space characters.