@@ -53,7 +53,8 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
53
53
if ( validationErrors . Any ( validationError => validationError . IsCritical ) )
54
54
return new [ ] { Summary . ValidationFailed ( title , resultsFolderPath , logFilePath , validationErrors ) } ;
55
55
56
- var benchmarksToRunCount = supportedBenchmarks . Sum ( benchmarkInfo => benchmarkInfo . BenchmarksCases . Length ) ;
56
+ int totalBenchmarkCount = supportedBenchmarks . Sum ( benchmarkInfo => benchmarkInfo . BenchmarksCases . Length ) ;
57
+ int benchmarksToRunCount = totalBenchmarkCount ;
57
58
compositeLogger . WriteLineHeader ( "// ***** BenchmarkRunner: Start *****" ) ;
58
59
compositeLogger . WriteLineHeader ( $ "// ***** Found { benchmarksToRunCount } benchmark(s) in total *****") ;
59
60
var globalChronometer = Chronometer . Start ( ) ;
@@ -74,13 +75,12 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
74
75
{
75
76
var runChronometer = Chronometer . Start ( ) ;
76
77
77
- var summary = Run ( benchmarkRunInfo , benchmarkToBuildResult , resolver , compositeLogger , artifactsToCleanup , resultsFolderPath , logFilePath , ref runChronometer ) ;
78
+ var summary = Run ( benchmarkRunInfo , benchmarkToBuildResult , resolver , compositeLogger , artifactsToCleanup ,
79
+ resultsFolderPath , logFilePath , totalBenchmarkCount , in globalChronometer , ref runChronometer , ref benchmarksToRunCount ) ;
78
80
79
81
if ( ! benchmarkRunInfo . Config . Options . IsSet ( ConfigOptions . JoinSummary ) )
80
82
PrintSummary ( compositeLogger , benchmarkRunInfo . Config , summary ) ;
81
83
82
- benchmarksToRunCount -= benchmarkRunInfo . BenchmarksCases . Length ;
83
- compositeLogger . WriteLineHeader ( $ "// ** Remained { benchmarksToRunCount } benchmark(s) to run **") ;
84
84
LogTotalTime ( compositeLogger , runChronometer . GetElapsed ( ) . GetTimeSpan ( ) , summary . GetNumberOfExecutedBenchmarks ( ) , message : "Run time" ) ;
85
85
compositeLogger . WriteLine ( ) ;
86
86
@@ -130,7 +130,10 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
130
130
List < string > artifactsToCleanup ,
131
131
string resultsFolderPath ,
132
132
string logFilePath ,
133
- ref StartedClock runChronometer )
133
+ int totalBenchmarkCount ,
134
+ in StartedClock globalChronometer ,
135
+ ref StartedClock runChronometer ,
136
+ ref int benchmarksToRunCount )
134
137
{
135
138
var benchmarks = benchmarkRunInfo . BenchmarksCases ;
136
139
var allBuildsHaveFailed = benchmarks . All ( benchmark => ! buildResults [ benchmark ] . buildResult . IsBuildSuccess ) ;
@@ -146,8 +149,12 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
146
149
147
150
using ( var powerManagementApplier = new PowerManagementApplier ( logger ) )
148
151
{
149
- foreach ( var benchmark in benchmarks )
152
+ bool stop = false ;
153
+
154
+ for ( int i = 0 ; i < benchmarks . Length && ! stop ; i ++ )
150
155
{
156
+ var benchmark = benchmarks [ i ] ;
157
+
151
158
powerManagementApplier . ApplyPerformancePlan ( benchmark . Job . Environment . PowerPlanMode
152
159
?? benchmark . Job . ResolveValue ( EnvironmentMode . PowerPlanModeCharacteristic , EnvironmentResolver . Instance ) . GetValueOrDefault ( ) ) ;
153
160
@@ -171,7 +178,9 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
171
178
}
172
179
173
180
if ( ! report . Success && config . Options . IsSet ( ConfigOptions . StopOnFirstError ) )
174
- break ;
181
+ {
182
+ stop = true ;
183
+ }
175
184
}
176
185
else
177
186
{
@@ -193,10 +202,16 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
193
202
}
194
203
195
204
if ( config . Options . IsSet ( ConfigOptions . StopOnFirstError ) || allBuildsHaveFailed )
196
- break ;
205
+ {
206
+ stop = true ;
207
+ }
197
208
}
198
209
199
210
logger . WriteLine ( ) ;
211
+
212
+ benchmarksToRunCount -= stop ? benchmarks . Length - i : 1 ;
213
+
214
+ LogProgress ( logger , in globalChronometer , totalBenchmarkCount , benchmarksToRunCount ) ;
200
215
}
201
216
}
202
217
@@ -638,5 +653,16 @@ private static void Cleanup(HashSet<string> artifactsToCleanup)
638
653
}
639
654
}
640
655
}
656
+
657
+ private static void LogProgress ( ILogger logger , in StartedClock globalChronometer , int totalBenchmarkCount , int benchmarksToRunCount )
658
+ {
659
+ int executedBenchmarkCount = totalBenchmarkCount - benchmarksToRunCount ;
660
+ double avgSecondsPerBenchmark = globalChronometer . GetElapsed ( ) . GetTimeSpan ( ) . TotalSeconds / executedBenchmarkCount ;
661
+ TimeSpan fromNow = TimeSpan . FromSeconds ( avgSecondsPerBenchmark * benchmarksToRunCount ) ;
662
+ DateTime estimatedEnd = DateTime . Now . Add ( fromNow ) ;
663
+ string message = $ "// ** Remained { benchmarksToRunCount } ({ ( double ) benchmarksToRunCount / totalBenchmarkCount : P1} ) benchmark(s) to run." +
664
+ $ " Estimated finish { estimatedEnd : yyyy-MM-dd H:mm} ({ ( int ) fromNow . TotalHours } h { fromNow . Minutes } m from now) **";
665
+ logger . WriteLineHeader ( message ) ;
666
+ }
641
667
}
642
668
}
0 commit comments