File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
src/BenchmarkDotNet/Running
tests/BenchmarkDotNet.IntegrationTests Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . IO ;
33using System . Reflection ;
4+ using System . Threading ;
45using BenchmarkDotNet . Characteristics ;
56using BenchmarkDotNet . Configs ;
67using BenchmarkDotNet . Environments ;
@@ -18,12 +19,20 @@ namespace BenchmarkDotNet.Running
1819{
1920 public class BuildPartition
2021 {
22+ // We use an auto-increment global counter instead of Guid to guarantee uniqueness per benchmark run (Guid has a small chance to collide),
23+ // assuming there are fewer than 4 billion build partitions (a safe assumption).
24+ internal static int s_partitionCounter ;
25+
2126 public BuildPartition ( BenchmarkBuildInfo [ ] benchmarks , IResolver resolver )
2227 {
2328 Resolver = resolver ;
2429 RepresentativeBenchmarkCase = benchmarks [ 0 ] . BenchmarkCase ;
2530 Benchmarks = benchmarks ;
26- ProgramName = benchmarks [ 0 ] . Config . Options . IsSet ( ConfigOptions . KeepBenchmarkFiles ) ? RepresentativeBenchmarkCase . Job . FolderInfo : Guid . NewGuid ( ) . ToString ( ) ;
31+ // Combine the benchmark's assembly name, folder info, and build partition id.
32+ string benchmarkAssemblyName = RepresentativeBenchmarkCase . Descriptor . Type . Assembly . GetName ( ) . Name ;
33+ string folderInfo = RepresentativeBenchmarkCase . Job . FolderInfo ;
34+ int id = Interlocked . Increment ( ref s_partitionCounter ) ;
35+ ProgramName = $ "{ benchmarkAssemblyName } -{ folderInfo } -{ id } ";
2736 LogBuildOutput = benchmarks [ 0 ] . Config . Options . IsSet ( ConfigOptions . LogBuildOutput ) ;
2837 GenerateMSBuildBinLog = benchmarks [ 0 ] . Config . Options . IsSet ( ConfigOptions . GenerateMSBuildBinLog ) ;
2938 }
Original file line number Diff line number Diff line change 1010using BenchmarkDotNet . Jobs ;
1111using BenchmarkDotNet . Loggers ;
1212using BenchmarkDotNet . Reports ;
13+ using BenchmarkDotNet . Running ;
1314using BenchmarkDotNet . Tests . Loggers ;
1415using BenchmarkDotNet . Tests . XUnit ;
1516using BenchmarkDotNet . Toolchains . InProcess . Emit ;
@@ -68,10 +69,13 @@ private void DiffEmit(Summary summary)
6869 if ( ! Portability . RuntimeInformation . IsFullFramework )
6970 return ;
7071
71- var caseName = summary . BenchmarksCases . First ( ) . Job . ToString ( ) ;
72+ var benchmarkCase = summary . BenchmarksCases . First ( ) ;
73+ var caseName = $ "{ benchmarkCase . Descriptor . Type . Assembly . GetName ( ) . Name } -{ benchmarkCase . Job . FolderInfo } ";
74+ // The benchmark config built jobs with 2 toolchains, 1 InProcessEmit and 1 Roslyn,
75+ // so we need to subtract 1 from the partition counter to obtain the emit output.
7276 NaiveRunnableEmitDiff . RunDiff (
73- $@ "{ caseName } .exe",
74- $@ "{ caseName } Emitted.dll",
77+ $@ "{ caseName } - { BuildPartition . s_partitionCounter } .exe",
78+ $@ "{ caseName } - { BuildPartition . s_partitionCounter - 1 } Emitted.dll",
7579 ConsoleLogger . Default ) ;
7680 }
7781
You can’t perform that action at this time.
0 commit comments