Class ConfigExtensions
ManualConfig and IConfig extension methods for replacing parts of an existing config - for example, default columns with custom ones.
When building a config in BenchmarkDotNet to run your benchmarks, there are essentially two ways of doing it:
- You can start from scratch with an empty config and most likely end up forgetting to add some essential item.
- You can use the predefined DefaultConfig.Instance and probably get some ingredients you don't have any use for, but which are hard to get rid of once they are part of the config.
This is where these extensions come in handy. You can use the default config - or any other preexisting one - and replace parts of it. Don't like the default three exporters (HTML, CSV, GitHub Markdown) and prefer the leaner Console Markdown exporter?
ManualConfig config = DefaultConfig.Instance.ReplaceExporters(MarkdownExporter.Console);
Only want the statistical Mean column, not all the other ones, like StdDev and Error?
ManualConfig config = DefaultConfig.Instance.ReplaceColumnCategory(StatisticColumn.Mean);
Which of course leads to the custom columns that are part of this library:
ManualConfig config = DefaultConfig.Instance.ReplaceColumnCategory(
new JobColumnSelectionProvider("-run +runstrategy"),
new RecyclableParamsColumnProvider()
);
Note
When you use the extensions with a ManualConfig, that config is modified and returned.
When you use the extensions with any other IConfig (as in the examples above), the source config remains untouched and a new instance of ManualConfig with the changes applied is returned.
Namespace: Mawosoft.Extensions.BenchmarkDotNet
Assembly: Mawosoft.Extensions.BenchmarkDotNet.dll
Syntax
public static class ConfigExtensions : Object
Methods
RemoveColumnsByCategory(IConfig, ColumnCategory[])
Removes existing columns of the specified category or categories.
Note
In BenchmarkDotNet, the ColumnCategory.Job encompasses not only the real job characteristic columns, but also the method descriptor columns and the categories column.
This method will not remove the latter two column types if the removal of ColumnCategory.Job is requested.
Declaration
public static ManualConfig RemoveColumnsByCategory(this IConfig config, params ColumnCategory[] categories)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
ColumnCategory[] | categories | The column categories to remove. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
RemoveColumnsByCategory(ManualConfig, ColumnCategory[])
Removes existing columns of the specified category or categories.
Note
In BenchmarkDotNet, the ColumnCategory.Job encompasses not only the real job characteristic columns, but also the method descriptor columns and the categories column.
This method will not remove the latter two column types if the removal of ColumnCategory.Job is requested.
Declaration
public static ManualConfig RemoveColumnsByCategory(this ManualConfig config, params ColumnCategory[] categories)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
ColumnCategory[] | categories | The column categories to remove. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceAnalysers(IConfig, IAnalyser[])
Replaces all analysers with the given new ones.
Declaration
public static ManualConfig ReplaceAnalysers(this IConfig config, params IAnalyser[] newAnalysers)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IAnalyser[] | newAnalysers | The new analyzers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceAnalysers(ManualConfig, IAnalyser[])
Replaces all analyzers with the given new ones.
Declaration
public static ManualConfig ReplaceAnalysers(this ManualConfig config, params IAnalyser[] newAnalysers)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IAnalyser[] | newAnalysers | The new analyzers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceColumnCategory(IConfig, IColumn[])
Replaces existing columns belonging to the same category or categories as newColumns
with the given new ones.
Declaration
public static ManualConfig ReplaceColumnCategory(this IConfig config, params IColumn[] newColumns)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IColumn[] | newColumns | The new columns to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceColumnCategory(IConfig, IColumnProvider[])
Replaces existing columns belonging to the same category or categories as newColumnProviders
with the given new ones.
Declaration
public static ManualConfig ReplaceColumnCategory(this IConfig config, params IColumnProvider[] newColumnProviders)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IColumnProvider[] | newColumnProviders | The new column providers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceColumnCategory(ManualConfig, IColumn[])
Replaces existing columns belonging to the same category or categories as newColumns
with the given new ones.
Declaration
public static ManualConfig ReplaceColumnCategory(this ManualConfig config, params IColumn[] newColumns)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IColumn[] | newColumns | The new columns to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceColumnCategory(ManualConfig, IColumnProvider[])
Replaces existing columns belonging to the same category or categories as newColumnProviders
with the given new ones.
Declaration
public static ManualConfig ReplaceColumnCategory(this ManualConfig config, params IColumnProvider[] newColumnProviders)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IColumnProvider[] | newColumnProviders | The new column providers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceDiagnosers(IConfig, IDiagnoser[])
Replaces all diagnosers with the given new ones.
Declaration
public static ManualConfig ReplaceDiagnosers(this IConfig config, params IDiagnoser[] newDiagnosers)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IDiagnoser[] | newDiagnosers | The new diagnosers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceDiagnosers(ManualConfig, IDiagnoser[])
Replaces all diagnosers with the given new ones.
Declaration
public static ManualConfig ReplaceDiagnosers(this ManualConfig config, params IDiagnoser[] newDiagnosers)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IDiagnoser[] | newDiagnosers | The new diagnosers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceExporters(IConfig, IExporter[])
Replaces all exporters with the given new ones.
Declaration
public static ManualConfig ReplaceExporters(this IConfig config, params IExporter[] newExporters)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IExporter[] | newExporters | The new exporters to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceExporters(ManualConfig, IExporter[])
Replaces all exporters with the given new ones.
Declaration
public static ManualConfig ReplaceExporters(this ManualConfig config, params IExporter[] newExporters)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IExporter[] | newExporters | The new exporters to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceFilters(IConfig, IFilter[])
Replaces all filters with the given new ones.
Declaration
public static ManualConfig ReplaceFilters(this IConfig config, params IFilter[] newFilters)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IFilter[] | newFilters | The new filters to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceFilters(ManualConfig, IFilter[])
Replaces all filters with the given new ones.
Declaration
public static ManualConfig ReplaceFilters(this ManualConfig config, params IFilter[] newFilters)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IFilter[] | newFilters | The new filters to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceHardwareCounters(IConfig, HardwareCounter[])
Replaces all hardware counters with the given new ones.
Declaration
public static ManualConfig ReplaceHardwareCounters(this IConfig config, params HardwareCounter[] newHardwareCounters)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
HardwareCounter[] | newHardwareCounters | The new hardware counters to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceHardwareCounters(ManualConfig, HardwareCounter[])
Replaces all hardware counters with the given new ones.
Declaration
public static ManualConfig ReplaceHardwareCounters(this ManualConfig config, params HardwareCounter[] newHardwareCounters)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
HardwareCounter[] | newHardwareCounters | The new hardware counters to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceJobs(IConfig, Job[])
Replaces all jobs with the given new ones.
Declaration
public static ManualConfig ReplaceJobs(this IConfig config, params Job[] newJobs)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
Job[] | newJobs | The new jobs to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceJobs(ManualConfig, Job[])
Replaces all jobs with the given new ones.
Declaration
public static ManualConfig ReplaceJobs(this ManualConfig config, params Job[] newJobs)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
Job[] | newJobs | The new jobs to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceLoggers(IConfig, ILogger[])
Replaces all loggers with the given new ones.
Declaration
public static ManualConfig ReplaceLoggers(this IConfig config, params ILogger[] newLoggers)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
ILogger[] | newLoggers | The new loggers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceLoggers(ManualConfig, ILogger[])
Replaces all loggers with the given new ones.
Declaration
public static ManualConfig ReplaceLoggers(this ManualConfig config, params ILogger[] newLoggers)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
ILogger[] | newLoggers | The new loggers to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceLogicalGroupRules(IConfig, BenchmarkLogicalGroupRule[])
Replaces all logical group rules with the given new ones.
Declaration
public static ManualConfig ReplaceLogicalGroupRules(this IConfig config, params BenchmarkLogicalGroupRule[] newLogicalGroupRules)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
BenchmarkLogicalGroupRule[] | newLogicalGroupRules | The new logical group rules to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceLogicalGroupRules(ManualConfig, BenchmarkLogicalGroupRule[])
Replaces all logical group rules with the given new ones.
Declaration
public static ManualConfig ReplaceLogicalGroupRules(this ManualConfig config, params BenchmarkLogicalGroupRule[] newLogicalGroupRules)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
BenchmarkLogicalGroupRule[] | newLogicalGroupRules | The new logical group rules to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |
ReplaceValidators(IConfig, IValidator[])
Replaces all validators with the given new ones.
Declaration
public static ManualConfig ReplaceValidators(this IConfig config, params IValidator[] newValidators)
Parameters
Type | Name | Description |
---|---|---|
IConfig | config | The source config. |
IValidator[] | newValidators | The new validators to be added. |
Returns
Type | Description |
---|---|
ManualConfig | A new instance of ManualConfig with changes applied. |
ReplaceValidators(ManualConfig, IValidator[])
Replaces all validators with the given new ones.
Declaration
public static ManualConfig ReplaceValidators(this ManualConfig config, params IValidator[] newValidators)
Parameters
Type | Name | Description |
---|---|---|
ManualConfig | config | The config to be changed. |
IValidator[] | newValidators | The new validators to be added. |
Returns
Type | Description |
---|---|
ManualConfig | The existing ManualConfig with changes applied. |