File tree 2 files changed +17
-4
lines changed
src/BenchmarkDotNet/Running
tests/BenchmarkDotNet.IntegrationTests
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . IO ;
3
3
using System . Reflection ;
4
+ using System . Threading ;
4
5
using BenchmarkDotNet . Characteristics ;
5
6
using BenchmarkDotNet . Configs ;
6
7
using BenchmarkDotNet . Environments ;
@@ -18,12 +19,20 @@ namespace BenchmarkDotNet.Running
18
19
{
19
20
public class BuildPartition
20
21
{
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
+
21
26
public BuildPartition ( BenchmarkBuildInfo [ ] benchmarks , IResolver resolver )
22
27
{
23
28
Resolver = resolver ;
24
29
RepresentativeBenchmarkCase = benchmarks [ 0 ] . BenchmarkCase ;
25
30
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 } ";
27
36
LogBuildOutput = benchmarks [ 0 ] . Config . Options . IsSet ( ConfigOptions . LogBuildOutput ) ;
28
37
GenerateMSBuildBinLog = benchmarks [ 0 ] . Config . Options . IsSet ( ConfigOptions . GenerateMSBuildBinLog ) ;
29
38
}
Original file line number Diff line number Diff line change 10
10
using BenchmarkDotNet . Jobs ;
11
11
using BenchmarkDotNet . Loggers ;
12
12
using BenchmarkDotNet . Reports ;
13
+ using BenchmarkDotNet . Running ;
13
14
using BenchmarkDotNet . Tests . Loggers ;
14
15
using BenchmarkDotNet . Tests . XUnit ;
15
16
using BenchmarkDotNet . Toolchains . InProcess . Emit ;
@@ -68,10 +69,13 @@ private void DiffEmit(Summary summary)
68
69
if ( ! Portability . RuntimeInformation . IsFullFramework )
69
70
return ;
70
71
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.
72
76
NaiveRunnableEmitDiff . RunDiff (
73
- $@ "{ caseName } .exe",
74
- $@ "{ caseName } Emitted.dll",
77
+ $@ "{ caseName } - { BuildPartition . s_partitionCounter } .exe",
78
+ $@ "{ caseName } - { BuildPartition . s_partitionCounter - 1 } Emitted.dll",
75
79
ConsoleLogger . Default ) ;
76
80
}
77
81
You can’t perform that action at this time.
0 commit comments