@@ -37,6 +37,7 @@ public class Summary
3737 private ImmutableDictionary < BenchmarkCase , BenchmarkReport > ReportMap { get ; }
3838 private BaseliningStrategy BaseliningStrategy { get ; }
3939 private bool ? isMultipleRuntimes ;
40+ private readonly BenchmarkCase inferredBaselineBenchmarkCase ;
4041
4142 public Summary (
4243 string title ,
@@ -62,13 +63,32 @@ public Summary(
6263 DisplayPrecisionManager = new DisplayPrecisionManager ( this ) ;
6364 Orderer = GetConfiguredOrdererOrDefaultOne ( reports . Select ( report => report . BenchmarkCase . Config ) ) ;
6465 BenchmarksCases = Orderer . GetSummaryOrder ( reports . Select ( report => report . BenchmarkCase ) . ToImmutableArray ( ) , this ) . ToImmutableArray ( ) ; // we sort it first
66+ inferredBaselineBenchmarkCase = GetFastestBenchmarkCase ( reports ) ;
6567 Reports = BenchmarksCases . Select ( b => ReportMap [ b ] ) . ToImmutableArray ( ) ; // we use sorted collection to re-create reports list
6668 BaseliningStrategy = BaseliningStrategy . Create ( BenchmarksCases ) ;
6769 Style = GetConfiguredSummaryStyleOrDefaultOne ( BenchmarksCases ) . WithCultureInfo ( cultureInfo ) ;
6870 Table = GetTable ( Style ) ;
6971 AllRuntimes = BuildAllRuntimes ( HostEnvironmentInfo , Reports ) ;
7072 }
7173
74+ private static BenchmarkCase GetFastestBenchmarkCase ( ImmutableArray < BenchmarkReport > reports )
75+ {
76+ if ( reports . Any ( ) && reports . All ( r => r . BenchmarkCase . Config . AutomaticBaselineMode == AutomaticBaselineMode . Fastest ) )
77+ {
78+ var fastestReport = reports . First ( ) ;
79+ foreach ( var report in reports . Skip ( 1 ) )
80+ {
81+ if ( report . ResultStatistics . Mean < fastestReport . ResultStatistics . Mean )
82+ {
83+ fastestReport = report ;
84+ }
85+ }
86+ return fastestReport . BenchmarkCase ;
87+ }
88+
89+ return null ;
90+ }
91+
7292 [ PublicAPI ] public bool HasReport ( BenchmarkCase benchmarkCase ) => ReportMap . ContainsKey ( benchmarkCase ) ;
7393
7494 /// <summary>
@@ -133,7 +153,11 @@ public string GetLogicalGroupKey(BenchmarkCase benchmarkCase)
133153 => Orderer . GetLogicalGroupKey ( BenchmarksCases , benchmarkCase ) ;
134154
135155 public bool IsBaseline ( BenchmarkCase benchmarkCase )
136- => BaseliningStrategy . IsBaseline ( benchmarkCase ) ;
156+ {
157+ return inferredBaselineBenchmarkCase != null
158+ ? inferredBaselineBenchmarkCase == benchmarkCase
159+ : BaseliningStrategy . IsBaseline ( benchmarkCase ) ;
160+ }
137161
138162 [ CanBeNull ]
139163 public BenchmarkCase GetBaseline ( string logicalGroupKey )
0 commit comments