Skip to content

Commit fd9f34f

Browse files
committed
Issue #1024: Add validations
1 parent deedc64 commit fd9f34f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/BenchmarkDotNet/Reports/Summary.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ private static BenchmarkCase GetFastestBenchmarkCase(ImmutableArray<BenchmarkRep
7676
if (reports.Any() && reports.All(r => r.BenchmarkCase.Config.AutomaticBaselineMode == AutomaticBaselineMode.Fastest))
7777
{
7878
var fastestReport = reports.First();
79-
foreach (var report in reports.Skip(1))
79+
if (fastestReport.ResultStatistics != null)
8080
{
81-
if (report.ResultStatistics.Mean < fastestReport.ResultStatistics.Mean)
81+
foreach (var report in reports.Skip(1).Where(r => r.ResultStatistics != null))
8282
{
83-
fastestReport = report;
83+
if (report.ResultStatistics.Mean < fastestReport.ResultStatistics.Mean)
84+
{
85+
fastestReport = report;
86+
}
8487
}
8588
}
8689
return fastestReport.BenchmarkCase;

src/BenchmarkDotNet/Validators/BaselineValidator.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ private BaselineValidator() { }
1414

1515
public IEnumerable<ValidationError> Validate(ValidationParameters input)
1616
{
17+
if (input.Config.AutomaticBaselineMode != Configs.AutomaticBaselineMode.None)
18+
{
19+
foreach (var benchmark in input.Benchmarks)
20+
{
21+
if (benchmark.Descriptor.Baseline || benchmark.Job.Meta.Baseline)
22+
{
23+
yield return new ValidationError(TreatsWarningsAsErrors, "You cannot use both pre-configured and automatic baseline configuration", benchmark);
24+
}
25+
}
26+
}
27+
1728
var allBenchmarks = input.Benchmarks.ToImmutableArray();
1829
var orderProvider = input.Config.Orderer;
1930

0 commit comments

Comments
 (0)