forked from dotnet/BenchmarkDotNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MaxIterationCount configurable, keep current value as default, f…
…ixes dotnet#763
- Loading branch information
1 parent
5f65863
commit a409803
Showing
10 changed files
with
98 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
using BenchmarkDotNet.Characteristics; | ||
using BenchmarkDotNet.Engines; | ||
using BenchmarkDotNet.Environments; | ||
using BenchmarkDotNet.Jobs; | ||
|
||
namespace BenchmarkDotNet.Validators | ||
{ | ||
public class RunModeValidator : IValidator | ||
{ | ||
public static readonly IValidator FailOnError = new RunModeValidator(); | ||
|
||
private RunModeValidator() { } | ||
|
||
public bool TreatsWarningsAsErrors => true; | ||
|
||
public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters) | ||
{ | ||
var resolver = new CompositeResolver(EnvResolver.Instance, EngineResolver.Instance); // TODO: use specified resolver. | ||
foreach (var benchmark in validationParameters.Benchmarks) | ||
{ | ||
var run = benchmark.Job.Run; | ||
int unrollFactor = run.ResolveValue(RunMode.UnrollFactorCharacteristic, resolver); | ||
if (unrollFactor <= 0) | ||
{ | ||
yield return new ValidationError(true, $"Specified UnrollFactor ({unrollFactor}) must be greater than zero", benchmark); | ||
} | ||
else if (run.HasValue(RunMode.InvocationCountCharacteristic)) | ||
{ | ||
int invocationCount = run.InvocationCount; | ||
if (invocationCount % unrollFactor != 0) | ||
{ | ||
string message = $"Specified InvocationCount ({invocationCount}) must be a multiple of UnrollFactor ({unrollFactor})"; | ||
yield return new ValidationError(true, message, benchmark); | ||
} | ||
} | ||
|
||
int minTargetCount = run.ResolveValue(RunMode.MinTargetIterationCountCharacteristic, resolver); | ||
int maxTargetCount = run.ResolveValue(RunMode.MaxTargetIterationCountCharacteristic, resolver); | ||
|
||
if (minTargetCount <= 0) | ||
yield return new ValidationError(true, $"{nameof(RunMode.MinTargetIterationCount)} must be greater than zero (was {minTargetCount})", benchmark); | ||
|
||
if (maxTargetCount <= 0) | ||
yield return new ValidationError(true, $"{nameof(RunMode.MaxTargetIterationCount)} must be greater than zero (was {maxTargetCount})", benchmark); | ||
|
||
if (minTargetCount >= maxTargetCount) | ||
yield return new ValidationError(true, $"{nameof(RunMode.MaxTargetIterationCount)} must be greater than {nameof(RunMode.MinTargetIterationCount)} (was {maxTargetCount} and {minTargetCount})", benchmark); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters