/// <summary> /// 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. /// <remarks>If <see cref="AccuracyMode.MaxRelativeError"/> is also provided, the smallest value is used as stop criteria.</remarks> /// </summary> public static Job WithMaxAbsoluteError(this Job job, TimeInterval interval) => job.WithCore(j => j.Accuracy.MaxAbsoluteError = interval);
/// <summary> /// Invocation count in a single iteration. /// If specified, <see cref="RunMode.IterationTime"/> will be ignored. /// If specified, it must be a multiple of <see cref="RunMode.UnrollFactor"/>. /// </summary> public static Job WithInvocationCount(this Job job, int count) => job.WithCore(j => j.Run.InvocationCount = count);
/// <summary> /// Maximum count of target iterations that should be performed. /// The default value is 100. /// <remarks>If you set this value to below 15, then <see cref="MultimodalDistributionAnalyzer"/> is not going to work.</remarks> /// </summary> public static Job WithMaxIterationCount(this Job job, int count) => job.WithCore(j => j.Run.MaxIterationCount = count);
public static Job With(this Job job, RunStrategy strategy) => job.WithCore(j => j.Run.RunStrategy = strategy); // Run /// <summary> /// 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. /// </summary> public static Job WithStrategy(this Job job, RunStrategy strategy) => job.WithCore(j => j.Run.RunStrategy = strategy);
/// <summary> /// How many warmup iterations should be performed. /// </summary> public static Job WithWarmupCount(this Job job, int count) => job.WithCore(j => j.Run.WarmupCount = count);
public static Job WithHeapCount(this Job job, int heapCount) => job.WithCore(j => j.Environment.Gc.HeapCount = heapCount);
public static Job WithHeapAffinitizeMask(this Job job, int heapAffinitizeMask) => job.WithCore(j => j.Environment.Gc.HeapAffinitizeMask = heapAffinitizeMask);
// Meta public static Job AsBaseline(this Job job) => job.WithCore(j => j.Meta.Baseline = true);
/// <summary> /// ProcessorAffinity for the benchmark process. /// See also: https://msdn.microsoft.com/library/system.diagnostics.process.processoraffinity.aspx /// </summary> public static Job WithAffinity(this Job job, IntPtr affinity) => job.WithCore(j => j.Environment.Affinity = affinity);
/// <summary> /// Specifies which outliers should be removed from the distribution /// </summary> public static Job WithOutlierMode(this Job job, OutlierMode value) => job.WithCore(j => j.Accuracy.OutlierMode = value);
public static Job WithAnalyzeLaunchVariance(this Job job, bool value) => job.WithCore(j => j.Accuracy.AnalyzeLaunchVariance = value);
/// <summary> /// 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. /// </summary> public static Job WithEvaluateOverhead(this Job job, bool value) => job.WithCore(j => j.Accuracy.EvaluateOverhead = value);
/// <summary> /// Minimum count of benchmark invocations per iteration /// The default value is 4. /// </summary> public static Job WithMinInvokeCount(this Job job, int value) => job.WithCore(j => j.Accuracy.MinInvokeCount = value);
/// <summary> /// 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. /// </summary> public static Job WithMinIterationTime(this Job job, TimeInterval interval) => job.WithCore(j => j.Accuracy.MinIterationTime = interval);
/// <summary> /// On 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size. /// <value>false: Arrays greater than 2 GB in total size are not enabled. This is the default.</value> /// <value>true: Arrays greater than 2 GB in total size are enabled on 64-bit platforms.</value> /// </summary> public static Job WithGcAllowVeryLargeObjects(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.AllowVeryLargeObjects = value);
public static Job WithBaseline(this Job job, bool value) => job.WithCore(j => j.Meta.Baseline = value);
public static Job WithGcRetainVm(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.RetainVm = value);
/// <summary> /// mutator job should not be added to the config, but instead applied to other jobs in given config /// </summary> public static Job AsMutator(this Job job) => job.WithCore(j => j.Meta.IsMutator = true);
public static Job WithNoAffinitize(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.NoAffinitize = value);
/// <summary> /// use it if you want to specify custom default settings for default job used by console arguments parser /// </summary> public static Job AsDefault(this Job job, bool value = true) => job.WithCore(j => j.Meta.IsDefault = value);
public static Job WithGcMode(this Job job, GcMode gc) => job.WithCore(j => EnvironmentMode.GcCharacteristic[j] = gc);
/// <summary> /// Specifies whether the common language runtime runs server garbage collection. /// <value>false: Does not run server garbage collection. This is the default.</value> /// <value>true: Runs server garbage collection.</value> /// </summary> public static Job WithGcServer(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.Server = value);
/// <summary> /// How many times we should launch process with target benchmark. /// </summary> public static Job WithLaunchCount(this Job job, int count) => job.WithCore(j => j.Run.LaunchCount = count);
/// <summary> /// Specifies whether the common language runtime runs garbage collection on a separate thread. /// <value>false: Does not run garbage collection concurrently.</value> /// <value>true: Runs garbage collection concurrently. This is the default.</value> /// </summary> public static Job WithGcConcurrent(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.Concurrent = value);
/// <summary> /// 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. /// </summary> public static Job WithIterationTime(this Job job, TimeInterval time) => job.WithCore(j => j.Run.IterationTime = time);
public static Job WithGcCpuGroups(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.CpuGroups = value);
/// <summary> /// How many times the benchmark method will be invoked per one iteration of a generated loop. /// The default value is 16. /// </summary> public static Job WithUnrollFactor(this Job job, int factor) => job.WithCore(j => j.Run.UnrollFactor = factor);
/// <summary> /// Specifies whether the BenchmarkDotNet's benchmark runner forces full garbage collection after each benchmark invocation /// <value>false: Does not force garbage collection.</value> /// <value>true: Forces full garbage collection after each benchmark invocation. This is the default.</value> /// </summary> public static Job WithGcForce(this Job job, bool value) => job.WithCore(j => j.Environment.Gc.Force = value);
public static Job WithPlatform(this Job job, Platform platform) => job.WithCore(j => j.Environment.Platform = platform);
// Accuracy /// <summary> /// 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. /// <remarks>If <see cref="AccuracyMode.MaxAbsoluteError"/> is also provided, the smallest value is used as stop criteria.</remarks> /// </summary> public static Job WithMaxRelativeError(this Job job, double value) => job.WithCore(j => j.Accuracy.MaxRelativeError = value);