17
17
using BenchmarkDotNet . Jobs ;
18
18
using BenchmarkDotNet . Loggers ;
19
19
using BenchmarkDotNet . Mathematics ;
20
- using BenchmarkDotNet . Portability ;
21
20
using BenchmarkDotNet . Reports ;
22
21
using BenchmarkDotNet . Toolchains ;
23
22
using BenchmarkDotNet . Toolchains . Parameters ;
@@ -168,15 +167,13 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
168
167
var cultureInfo = config . CultureInfo ?? DefaultCultureInfo . Instance ;
169
168
var reports = new List < BenchmarkReport > ( ) ;
170
169
string title = GetTitle ( new [ ] { benchmarkRunInfo } ) ;
171
- var consoleTitle = RuntimeInformation . IsWindows ( ) ? Console . Title : string . Empty ;
170
+ using var consoleTitler = new ConsoleTitler ( $ " { benchmarksToRunCount } / { totalBenchmarkCount } Remaining" ) ;
172
171
173
172
logger . WriteLineInfo ( $ "// Found { benchmarks . Length } benchmarks:") ;
174
173
foreach ( var benchmark in benchmarks )
175
174
logger . WriteLineInfo ( $ "// { benchmark . DisplayInfo } ") ;
176
175
logger . WriteLine ( ) ;
177
176
178
- UpdateTitle ( totalBenchmarkCount , benchmarksToRunCount ) ;
179
-
180
177
using ( var powerManagementApplier = new PowerManagementApplier ( logger ) )
181
178
{
182
179
bool stop = false ;
@@ -241,15 +238,10 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
241
238
242
239
benchmarksToRunCount -= stop ? benchmarks . Length - i : 1 ;
243
240
244
- LogProgress ( logger , in runsChronometer , totalBenchmarkCount , benchmarksToRunCount , taskbarProgress ) ;
241
+ LogProgress ( logger , in runsChronometer , totalBenchmarkCount , benchmarksToRunCount , consoleTitler , taskbarProgress ) ;
245
242
}
246
243
}
247
244
248
- if ( RuntimeInformation . IsWindows ( ) )
249
- {
250
- Console . Title = consoleTitle ;
251
- }
252
-
253
245
var runEnd = runsChronometer . GetElapsed ( ) ;
254
246
255
247
return new Summary ( title ,
@@ -652,15 +644,7 @@ private static void Cleanup(HashSet<string> artifactsToCleanup)
652
644
}
653
645
}
654
646
655
- private static void UpdateTitle ( int totalBenchmarkCount , int benchmarksToRunCount )
656
- {
657
- if ( ! Console . IsOutputRedirected && ( RuntimeInformation . IsWindows ( ) || RuntimeInformation . IsLinux ( ) || RuntimeInformation . IsMacOS ( ) ) )
658
- {
659
- Console . Title = $ "{ benchmarksToRunCount } /{ totalBenchmarkCount } Remaining";
660
- }
661
- }
662
-
663
- private static void LogProgress ( ILogger logger , in StartedClock runsChronometer , int totalBenchmarkCount , int benchmarksToRunCount , TaskbarProgress taskbarProgress )
647
+ private static void LogProgress ( ILogger logger , in StartedClock runsChronometer , int totalBenchmarkCount , int benchmarksToRunCount , ConsoleTitler consoleTitler , TaskbarProgress taskbarProgress )
664
648
{
665
649
int executedBenchmarkCount = totalBenchmarkCount - benchmarksToRunCount ;
666
650
TimeSpan fromNow = GetEstimatedFinishTime ( runsChronometer , benchmarksToRunCount , executedBenchmarkCount ) ;
@@ -669,10 +653,8 @@ private static void LogProgress(ILogger logger, in StartedClock runsChronometer,
669
653
$ " Estimated finish { estimatedEnd : yyyy-MM-dd H:mm} ({ ( int ) fromNow . TotalHours } h { fromNow . Minutes } m from now) **";
670
654
logger . WriteLineHeader ( message ) ;
671
655
672
- if ( ! Console . IsOutputRedirected && ( RuntimeInformation . IsWindows ( ) || RuntimeInformation . IsLinux ( ) || RuntimeInformation . IsMacOS ( ) ) )
673
- {
674
- Console . Title = $ "{ benchmarksToRunCount } /{ totalBenchmarkCount } Remaining - { ( int ) fromNow . TotalHours } h { fromNow . Minutes } m to finish";
675
- }
656
+ consoleTitler . UpdateTitle ( $ "{ benchmarksToRunCount } /{ totalBenchmarkCount } Remaining - { ( int ) fromNow . TotalHours } h { fromNow . Minutes } m to finish") ;
657
+
676
658
taskbarProgress . SetProgress ( ( float ) executedBenchmarkCount / totalBenchmarkCount ) ;
677
659
}
678
660
@@ -728,4 +710,4 @@ private static int GetIdToResume(string rootArtifactsFolderPath, string currentL
728
710
return - 1 ;
729
711
}
730
712
}
731
- }
713
+ }
0 commit comments