Class JobExtensions
- Namespace
- BenchmarkDotNet.Jobs
- Assembly
- BenchmarkDotNet.dll
public static class JobExtensions
- Inheritance
-
JobExtensions
Methods
AsBaseline(Job)
public static Job AsBaseline(this Job job)
Parameters
job
Job
Returns
AsDefault(Job, bool)
use it if you want to specify custom default settings for default job used by console arguments parser
public static Job AsDefault(this Job job, bool value = true)
Parameters
Returns
AsMutator(Job)
mutator job should not be added to the config, but instead applied to other jobs in given config
public static Job AsMutator(this Job job)
Parameters
job
Job
Returns
DontEnforcePowerPlan(Job)
ensures that BenchmarkDotNet does not enforce any power plan
public static Job DontEnforcePowerPlan(this Job job)
Parameters
job
Job
Returns
RunOncePerIteration(Job)
Run the benchmark exactly once per iteration.
public static Job RunOncePerIteration(this Job job)
Parameters
job
Job
Returns
WithAffinity(Job, nint)
ProcessorAffinity for the benchmark process. See also: https://msdn.microsoft.com/library/system.diagnostics.process.processoraffinity.aspx
public static Job WithAffinity(this Job job, nint affinity)
Parameters
Returns
WithAnalyzeLaunchVariance(Job, bool)
public static Job WithAnalyzeLaunchVariance(this Job job, bool value)
Parameters
Returns
WithArguments(Job, IReadOnlyList<Argument>)
public static Job WithArguments(this Job job, IReadOnlyList<Argument> arguments)
Parameters
job
Jobarguments
IReadOnlyList<Argument>
Returns
WithBaseline(Job, bool)
public static Job WithBaseline(this Job job, bool value)
Parameters
Returns
WithClock(Job, IClock)
public static Job WithClock(this Job job, IClock clock)
Parameters
job
Jobclock
IClock
Returns
WithCustomBuildConfiguration(Job, string)
public static Job WithCustomBuildConfiguration(this Job job, string buildConfiguration)
Parameters
Returns
WithEngineFactory(Job, IEngineFactory)
public static Job WithEngineFactory(this Job job, IEngineFactory engineFactory)
Parameters
job
JobengineFactory
IEngineFactory
Returns
WithEnvironmentVariable(Job, EnvironmentVariable)
Creates a new job based on the given job with additional environment variable. All existed environment variables of the original job will be copied to the new one. If the original job already contains an environment variable with the same key, it will be overriden.
public static Job WithEnvironmentVariable(this Job job, EnvironmentVariable environmentVariable)
Parameters
job
JobThe original job
environmentVariable
EnvironmentVariableThe new environment variable which should be added for the new job
Returns
- Job
The new job with additional environment variable
WithEnvironmentVariable(Job, string, string)
Creates a new job based on the given job with additional environment variable. All existed environment variables of the original job will be copied to the new one. If the original job already contains an environment variable with the same key, it will be overriden.
public static Job WithEnvironmentVariable(this Job job, string key, string value)
Parameters
job
JobThe original job
key
stringThe key of the new environment variable
value
stringThe value of the new environment variable
Returns
- Job
The new job with additional environment variable
WithEnvironmentVariables(Job, params EnvironmentVariable[])
Creates a new job based on the given job with specified environment variables. It overrides the whole list of environment variables which were defined in the original job.
public static Job WithEnvironmentVariables(this Job job, params EnvironmentVariable[] environmentVariables)
Parameters
job
JobThe original job
environmentVariables
EnvironmentVariable[]The environment variables for the new job
Returns
- Job
The new job with overriden environment variables
Exceptions
- InvalidOperationException
Throws an exception if
environmentVariables
contains two variables with the same key.
WithEvaluateOverhead(Job, bool)
Specifies if the overhead should be evaluated (Idle runs) and it's average value subtracted from every result. True by default, very important for nano-benchmarks.
public static Job WithEvaluateOverhead(this Job job, bool value)
Parameters
Returns
WithGcAllowVeryLargeObjects(Job, bool)
On 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size.
public static Job WithGcAllowVeryLargeObjects(this Job job, bool value)
Parameters
Returns
WithGcConcurrent(Job, bool)
Specifies whether the common language runtime runs garbage collection on a separate thread.
public static Job WithGcConcurrent(this Job job, bool value)
Parameters
Returns
WithGcCpuGroups(Job, bool)
Specifies whether garbage collection supports multiple CPU groups.
public static Job WithGcCpuGroups(this Job job, bool value)
Parameters
Returns
WithGcForce(Job, bool)
Specifies whether the BenchmarkDotNet's benchmark runner forces full garbage collection after each benchmark invocation
public static Job WithGcForce(this Job job, bool value)
Parameters
Returns
WithGcMode(Job, GcMode)
public static Job WithGcMode(this Job job, GcMode gc)
Parameters
Returns
WithGcRetainVm(Job, bool)
Put segments that should be deleted on a standby list for future use instead of releasing them back to the OS
public static Job WithGcRetainVm(this Job job, bool value)
Parameters
Returns
WithGcServer(Job, bool)
Specifies whether the common language runtime runs server garbage collection.
public static Job WithGcServer(this Job job, bool value)
Parameters
Returns
WithHeapAffinitizeMask(Job, int)
process mask, see MSDN for more.
public static Job WithHeapAffinitizeMask(this Job job, int heapAffinitizeMask)
Parameters
Returns
WithHeapCount(Job, int)
specify the # of Server GC threads/heaps, must be smaller than the # of logical CPUs the process is allowed to run on, ie, if you don't specifically affinitize your process it means the # of total logical CPUs on the machine; otherwise this is the # of logical CPUs you affinitized your process to.
public static Job WithHeapCount(this Job job, int heapCount)
Parameters
Returns
WithId(Job, string)
public static Job WithId(this Job job, string id)
Parameters
Returns
WithInvocationCount(Job, long)
Invocation count in a single iteration. If specified, IterationTime will be ignored. If specified, it must be a multiple of UnrollFactor.
public static Job WithInvocationCount(this Job job, long count)
Parameters
Returns
WithIterationCount(Job, int)
How many target iterations should be performed. If specified, MinIterationCount will be ignored. If specified, MaxIterationCount will be ignored.
public static Job WithIterationCount(this Job job, int count)
Parameters
Returns
WithIterationTime(Job, TimeInterval)
Desired time of execution of an iteration. Used by Pilot stage to estimate the number of invocations per iteration. The default value is 500 milliseconds.
public static Job WithIterationTime(this Job job, TimeInterval time)
Parameters
job
Jobtime
TimeInterval
Returns
WithJit(Job, Jit)
public static Job WithJit(this Job job, Jit jit)
Parameters
Returns
WithLargeAddressAware(Job, bool)
Specifies that benchmark can handle addresses larger than 2 gigabytes.
public static Job WithLargeAddressAware(this Job job, bool value = true)
Parameters
Returns
WithLaunchCount(Job, int)
How many times we should launch process with target benchmark.
public static Job WithLaunchCount(this Job job, int count)
Parameters
Returns
WithMaxAbsoluteError(Job, TimeInterval)
Maximum acceptable error for a benchmark (by default, BenchmarkDotNet continue iterations until the actual error is less than the specified error).
Doesn't have a default value.
public static Job WithMaxAbsoluteError(this Job job, TimeInterval interval)
Parameters
job
Jobinterval
TimeInterval
Returns
WithMaxIterationCount(Job, int)
Maximum count of target iterations that should be performed.
The default value is 100.
public static Job WithMaxIterationCount(this Job job, int count)
Parameters
Returns
WithMaxRelativeError(Job, double)
Maximum acceptable error for a benchmark (by default, BenchmarkDotNet continue iterations until the actual error is less than the specified error).
The default value is 0.02.
public static Job WithMaxRelativeError(this Job job, double value)
Parameters
Returns
WithMaxWarmupCount(Job, int)
Maximum count of warmup iterations that should be performed The default value is 50
public static Job WithMaxWarmupCount(this Job job, int count)
Parameters
Returns
WithMemoryRandomization(Job, bool)
specifies whether Engine should allocate some random-sized memory between iterations
public static Job WithMemoryRandomization(this Job job, bool enable = true)
Parameters
Returns
WithMinInvokeCount(Job, int)
Minimum count of benchmark invocations per iteration The default value is 4.
public static Job WithMinInvokeCount(this Job job, int value)
Parameters
Returns
WithMinIterationCount(Job, int)
Minimum count of target iterations that should be performed.
The default value is 15.
public static Job WithMinIterationCount(this Job job, int count)
Parameters
Returns
WithMinIterationTime(Job, TimeInterval)
Minimum time of a single iteration. Unlike Run.IterationTime, this characteristic specifies only the lower limit. In case of need, BenchmarkDotNet can increase this value. The default value is 500 milliseconds.
public static Job WithMinIterationTime(this Job job, TimeInterval interval)
Parameters
job
Jobinterval
TimeInterval
Returns
WithMinWarmupCount(Job, int)
Minimum count of warmup iterations that should be performed The default value is 6
public static Job WithMinWarmupCount(this Job job, int count)
Parameters
Returns
WithNoAffinitize(Job, bool)
specify true to disable hard affinity of Server GC threads to CPUs
public static Job WithNoAffinitize(this Job job, bool value)
Parameters
Returns
WithNuGet(Job, NuGetReferenceList)
Runs the job with a specific NuGet dependencies which will be resolved during the Job build process
public static Job WithNuGet(this Job job, NuGetReferenceList nuGetReferences)
Parameters
job
JobnuGetReferences
NuGetReferenceListA collection of NuGet dependencies
Returns
WithNuGet(Job, string, string?, Uri?, bool)
Runs the job with a specific NuGet dependency which will be resolved during the Job build process
public static Job WithNuGet(this Job job, string packageName, string? packageVersion = null, Uri? source = null, bool prerelease = false)
Parameters
job
JobpackageName
stringThe NuGet package name
packageVersion
string(optional)The NuGet package version
source
Uri(optional)Indicate the URI of the NuGet package source to use during the restore operation.
prerelease
bool(optional)Allows prerelease packages to be installed.
Returns
WithOutlierMode(Job, OutlierMode)
Specifies which outliers should be removed from the distribution
public static Job WithOutlierMode(this Job job, OutlierMode value)
Parameters
job
Jobvalue
OutlierMode
Returns
WithPlatform(Job, Platform)
public static Job WithPlatform(this Job job, Platform platform)
Parameters
Returns
WithPowerPlan(Job, PowerPlan)
Power plan for benchmarks.
The default value is HighPerformance.
public static Job WithPowerPlan(this Job job, PowerPlan powerPlan)
Parameters
Returns
WithPowerPlan(Job, Guid)
Setting power plans by guid.
The default value is HighPerformance.
public static Job WithPowerPlan(this Job job, Guid powerPlanGuid)
Parameters
Returns
WithRuntime(Job, Runtime)
public static Job WithRuntime(this Job job, Runtime runtime)
Parameters
Returns
WithStrategy(Job, RunStrategy)
Available values: Throughput, ColdStart and Monitoring. Throughput: default strategy which allows to get good precision level. ColdStart: should be used only for measuring cold start of the application or testing purpose. Monitoring: no overhead evaluating, with several target iterations. Perfect for macrobenchmarks without a steady state with high variance.
public static Job WithStrategy(this Job job, RunStrategy strategy)
Parameters
job
Jobstrategy
RunStrategy
Returns
WithToolchain(Job, IToolchain)
public static Job WithToolchain(this Job job, IToolchain toolchain)
Parameters
job
Jobtoolchain
IToolchain
Returns
WithUnrollFactor(Job, int)
How many times the benchmark method will be invoked per one iteration of a generated loop. The default value is 16.
public static Job WithUnrollFactor(this Job job, int factor)
Parameters
Returns
WithWarmupCount(Job, int)
How many warmup iterations should be performed.
public static Job WithWarmupCount(this Job job, int count)
Parameters
Returns
WithoutEnvironmentVariables(Job)
Creates a new job based on the given job without any environment variables.
public static Job WithoutEnvironmentVariables(this Job job)
Parameters
job
JobThe original job
Returns
- Job
The new job which doesn't have any environment variables