@@ -87,7 +87,7 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
8787
8888 var buildPartitions = BenchmarkPartitioner . CreateForBuild ( supportedBenchmarks , resolver ) ;
8989 eventProcessor . OnStartBuildStage ( buildPartitions ) ;
90- var buildResults = BuildInParallel ( compositeLogger , rootArtifactsFolderPath , buildPartitions , in globalChronometer , eventProcessor ) ;
90+ var buildResults = Build ( compositeLogger , rootArtifactsFolderPath , buildPartitions , in globalChronometer , eventProcessor ) ;
9191
9292 var allBuildsHaveFailed = buildResults . Values . All ( buildResult => ! buildResult . IsBuildSuccess ) ;
9393
@@ -370,52 +370,24 @@ private static ImmutableArray<ValidationError> Validate(params BenchmarkRunInfo[
370370 return validationErrors . ToImmutableArray ( ) ;
371371 }
372372
373- private static Dictionary < BuildPartition , BuildResult > BuildInParallel ( ILogger logger , string rootArtifactsFolderPath , BuildPartition [ ] buildPartitions , in StartedClock globalChronometer , EventProcessor eventProcessor )
373+ private static Dictionary < BuildPartition , BuildResult > Build ( ILogger logger , string rootArtifactsFolderPath , BuildPartition [ ] buildPartitions , in StartedClock globalChronometer , EventProcessor eventProcessor )
374374 {
375- logger . WriteLineHeader ( $ "// ***** Building { buildPartitions . Length } exe(s) in Parallel : Start *****") ;
375+ logger . WriteLineHeader ( $ "// ***** Building { buildPartitions . Length } exe(s): Start *****") ;
376376
377- var buildLogger = buildPartitions . Length == 1 ? logger : NullLogger . Instance ; // when we have just one partition we can print to std out
378-
379- var beforeParallelBuild = globalChronometer . GetElapsed ( ) ;
377+ var beforeBuild = globalChronometer . GetElapsed ( ) ;
380378
381379 var buildResults = buildPartitions
382- . AsParallel ( )
383- . Select ( buildPartition => ( Partition : buildPartition , Result : Build ( buildPartition , rootArtifactsFolderPath , buildLogger ) ) )
384- . AsSequential ( ) // Ensure that build completion events are processed sequentially
385- . Select ( build =>
380+ . Select ( buildPartition =>
386381 {
387- // If the generation was successful, but the build was not, we will try building sequentially
388- // so don't send the OnBuildComplete event yet.
389- if ( buildPartitions . Length <= 1 || ! build . Result . IsGenerateSuccess || build . Result . IsBuildSuccess )
390- eventProcessor . OnBuildComplete ( build . Partition , build . Result ) ;
391-
392- return build ;
382+ var buildResult = Build ( buildPartition , rootArtifactsFolderPath , logger ) ;
383+ eventProcessor . OnBuildComplete ( buildPartition , buildResult ) ;
384+ return ( buildPartition , buildResult ) ;
393385 } )
394- . ToDictionary ( build => build . Partition , build => build . Result ) ;
395-
396- var afterParallelBuild = globalChronometer . GetElapsed ( ) ;
397-
398- logger . WriteLineHeader ( $ "// ***** Done, took { GetFormattedDifference ( beforeParallelBuild , afterParallelBuild ) } *****") ;
399-
400- if ( buildPartitions . Length <= 1 || ! buildResults . Values . Any ( result => result . IsGenerateSuccess && ! result . IsBuildSuccess ) )
401- return buildResults ;
402-
403- logger . WriteLineHeader ( "// ***** Failed to build in Parallel, switching to sequential build *****" ) ;
404-
405- foreach ( var buildPartition in buildPartitions )
406- {
407- if ( buildResults [ buildPartition ] . IsGenerateSuccess && ! buildResults [ buildPartition ] . IsBuildSuccess )
408- {
409- if ( ! buildResults [ buildPartition ] . TryToExplainFailureReason ( out string _ ) )
410- buildResults [ buildPartition ] = Build ( buildPartition , rootArtifactsFolderPath , buildLogger ) ;
411-
412- eventProcessor . OnBuildComplete ( buildPartition , buildResults [ buildPartition ] ) ;
413- }
414- }
386+ . ToDictionary ( result => result . buildPartition , result => result . buildResult ) ;
415387
416- var afterSequentialBuild = globalChronometer . GetElapsed ( ) ;
388+ var afterBuild = globalChronometer . GetElapsed ( ) ;
417389
418- logger . WriteLineHeader ( $ "// ***** Done, took { GetFormattedDifference ( afterParallelBuild , afterSequentialBuild ) } *****") ;
390+ logger . WriteLineHeader ( $ "// ***** Done, took { GetFormattedDifference ( beforeBuild , afterBuild ) } *****") ;
419391
420392 return buildResults ;
421393
0 commit comments