@@ -82,9 +82,32 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
82
82
var globalChronometer = Chronometer . Start ( ) ;
83
83
84
84
85
- var buildPartitions = BenchmarkPartitioner . CreateForBuild ( supportedBenchmarks , resolver ) ;
86
- eventProcessor . OnStartBuildStage ( buildPartitions ) ;
87
- var buildResults = BuildInParallel ( compositeLogger , rootArtifactsFolderPath , buildPartitions , in globalChronometer , eventProcessor ) ;
85
+ var parallelBuildBenchmarks = supportedBenchmarks . Where ( x => ! x . Config . Options . IsSet ( ConfigOptions . DisableParallelBuild ) ) . ToArray ( ) ;
86
+ var parallelBuildPartitions = BenchmarkPartitioner . CreateForBuild ( parallelBuildBenchmarks , resolver ) ;
87
+
88
+ var sequentialBuildBenchmarks = supportedBenchmarks . Where ( x => x . Config . Options . IsSet ( ConfigOptions . DisableParallelBuild ) ) . ToArray ( ) ;
89
+ var sequentialBuildPartitions = BenchmarkPartitioner . CreateForBuild ( sequentialBuildBenchmarks , resolver ) ;
90
+
91
+ eventProcessor . OnStartBuildStage ( [ .. parallelBuildPartitions , .. sequentialBuildPartitions ] ) ;
92
+
93
+ var buildResults = new Dictionary < BuildPartition , BuildResult > ( ) ;
94
+ if ( parallelBuildBenchmarks . Length > 0 )
95
+ {
96
+ var results = BuildInParallel ( compositeLogger , rootArtifactsFolderPath , parallelBuildPartitions , in globalChronometer , eventProcessor ) ;
97
+ foreach ( var kvp in results )
98
+ {
99
+ buildResults . Add ( kvp . Key , kvp . Value ) ;
100
+ }
101
+ }
102
+
103
+ if ( sequentialBuildBenchmarks . Length > 0 )
104
+ {
105
+ var results = BuildSequential ( compositeLogger , rootArtifactsFolderPath , sequentialBuildPartitions , in globalChronometer , eventProcessor ) ;
106
+ foreach ( var kvp in results )
107
+ {
108
+ buildResults . Add ( kvp . Key , kvp . Value ) ;
109
+ }
110
+ }
88
111
89
112
var allBuildsHaveFailed = buildResults . Values . All ( buildResult => ! buildResult . IsBuildSuccess ) ;
90
113
@@ -404,10 +427,30 @@ private static Dictionary<BuildPartition, BuildResult> BuildInParallel(ILogger l
404
427
logger . WriteLineHeader ( $ "// ***** Done, took { GetFormattedDifference ( afterParallelBuild , afterSequentialBuild ) } *****") ;
405
428
406
429
return buildResults ;
430
+ }
431
+
432
+ private static Dictionary < BuildPartition , BuildResult > BuildSequential ( ILogger logger , string rootArtifactsFolderPath , BuildPartition [ ] buildPartitions , in StartedClock globalChronometer , EventProcessor eventProcessor )
433
+ {
434
+ logger . WriteLineHeader ( $ "// ***** Building { buildPartitions . Length } exe(s) in Sequential: Start *****") ;
435
+
436
+ var beforeBuild = globalChronometer . GetElapsed ( ) ;
437
+
438
+ var buildResults = new Dictionary < BuildPartition , BuildResult > ( ) ;
439
+ foreach ( var buildPartition in buildPartitions )
440
+ {
441
+ buildResults [ buildPartition ] = Build ( buildPartition , rootArtifactsFolderPath , logger ) ;
442
+ eventProcessor . OnBuildComplete ( buildPartition , buildResults [ buildPartition ] ) ;
443
+ }
444
+
445
+ var afterBuild = globalChronometer . GetElapsed ( ) ;
446
+
447
+ logger . WriteLineHeader ( $ "// ***** Done, took { GetFormattedDifference ( beforeBuild , afterBuild ) } *****") ;
448
+
449
+ return buildResults ;
450
+ }
407
451
408
- static string GetFormattedDifference ( ClockSpan before , ClockSpan after )
452
+ private static string GetFormattedDifference ( ClockSpan before , ClockSpan after )
409
453
=> ( after . GetTimeSpan ( ) - before . GetTimeSpan ( ) ) . ToFormattedTotalTime ( DefaultCultureInfo . Instance ) ;
410
- }
411
454
412
455
private static BuildResult Build ( BuildPartition buildPartition , string rootArtifactsFolderPath , ILogger buildLogger )
413
456
{
0 commit comments