1717using BenchmarkDotNet . Jobs ;
1818using BenchmarkDotNet . Loggers ;
1919using BenchmarkDotNet . Mathematics ;
20- using BenchmarkDotNet . Portability ;
2120using BenchmarkDotNet . Reports ;
2221using BenchmarkDotNet . Toolchains ;
2322using BenchmarkDotNet . Toolchains . Parameters ;
@@ -168,15 +167,13 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
168167 var cultureInfo = config . CultureInfo ?? DefaultCultureInfo . Instance ;
169168 var reports = new List < BenchmarkReport > ( ) ;
170169 string title = GetTitle ( new [ ] { benchmarkRunInfo } ) ;
171- var consoleTitle = RuntimeInformation . IsWindows ( ) ? Console . Title : string . Empty ;
170+ using var consoleTitler = new ConsoleTitler ( $ " { benchmarksToRunCount } / { totalBenchmarkCount } Remaining" ) ;
172171
173172 logger . WriteLineInfo ( $ "// Found { benchmarks . Length } benchmarks:") ;
174173 foreach ( var benchmark in benchmarks )
175174 logger . WriteLineInfo ( $ "// { benchmark . DisplayInfo } ") ;
176175 logger . WriteLine ( ) ;
177176
178- UpdateTitle ( totalBenchmarkCount , benchmarksToRunCount ) ;
179-
180177 using ( var powerManagementApplier = new PowerManagementApplier ( logger ) )
181178 {
182179 bool stop = false ;
@@ -241,15 +238,10 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
241238
242239 benchmarksToRunCount -= stop ? benchmarks . Length - i : 1 ;
243240
244- LogProgress ( logger , in runsChronometer , totalBenchmarkCount , benchmarksToRunCount , taskbarProgress ) ;
241+ LogProgress ( logger , in runsChronometer , totalBenchmarkCount , benchmarksToRunCount , consoleTitler , taskbarProgress ) ;
245242 }
246243 }
247244
248- if ( RuntimeInformation . IsWindows ( ) )
249- {
250- Console . Title = consoleTitle ;
251- }
252-
253245 var runEnd = runsChronometer . GetElapsed ( ) ;
254246
255247 return new Summary ( title ,
@@ -652,15 +644,7 @@ private static void Cleanup(HashSet<string> artifactsToCleanup)
652644 }
653645 }
654646
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 )
664648 {
665649 int executedBenchmarkCount = totalBenchmarkCount - benchmarksToRunCount ;
666650 TimeSpan fromNow = GetEstimatedFinishTime ( runsChronometer , benchmarksToRunCount , executedBenchmarkCount ) ;
@@ -669,10 +653,8 @@ private static void LogProgress(ILogger logger, in StartedClock runsChronometer,
669653 $ " Estimated finish { estimatedEnd : yyyy-MM-dd H:mm} ({ ( int ) fromNow . TotalHours } h { fromNow . Minutes } m from now) **";
670654 logger . WriteLineHeader ( message ) ;
671655
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+
676658 taskbarProgress . SetProgress ( ( float ) executedBenchmarkCount / totalBenchmarkCount ) ;
677659 }
678660
@@ -728,4 +710,4 @@ private static int GetIdToResume(string rootArtifactsFolderPath, string currentL
728710 return - 1 ;
729711 }
730712 }
731- }
713+ }
0 commit comments