Skip to content

Commit 35ebd29

Browse files
Better job id generation in SimpleJobAttribute
1 parent 6e13ba2 commit 35ebd29

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/BenchmarkDotNet/Attributes/Jobs/SimpleJobAttribute.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,55 @@ private static Job CreateJob(string id, int launchCount, int warmupCount, int ta
6060
bool baseline, RuntimeMoniker runtimeMoniker = RuntimeMoniker.HostProcess)
6161
{
6262
var job = new Job(id);
63+
int manualValuesCount = 0;
64+
6365
if (launchCount != DefaultValue)
66+
{
6467
job.Run.LaunchCount = launchCount;
68+
manualValuesCount++;
69+
}
70+
6571
if (warmupCount != DefaultValue)
72+
{
6673
job.Run.WarmupCount = warmupCount;
74+
manualValuesCount++;
75+
}
76+
6777
if (targetCount != DefaultValue)
78+
{
6879
job.Run.IterationCount = targetCount;
80+
manualValuesCount++;
81+
}
6982
if (invocationCount != DefaultValue)
7083
{
7184
job.Run.InvocationCount = invocationCount;
85+
manualValuesCount++;
86+
7287
int unrollFactor = job.Run.ResolveValue(RunMode.UnrollFactorCharacteristic, EnvironmentResolver.Instance);
7388
if (invocationCount % unrollFactor != 0)
89+
{
7490
job.Run.UnrollFactor = 1;
91+
manualValuesCount++;
92+
}
7593
}
7694

7795
if (runStrategy != null)
96+
{
7897
job.Run.RunStrategy = runStrategy.Value;
98+
manualValuesCount++;
99+
}
100+
79101
if (baseline)
80102
job.Meta.Baseline = true;
103+
81104
if (runtimeMoniker != RuntimeMoniker.HostProcess)
105+
{
82106
job.Environment.Runtime = runtimeMoniker.GetRuntime();
107+
manualValuesCount++;
108+
}
109+
110+
if (id == null && manualValuesCount == 1 && runtimeMoniker != RuntimeMoniker.HostProcess)
111+
job = job.WithId(runtimeMoniker.GetRuntime().Name);
83112

84113
return job.Freeze();
85114
}

0 commit comments

Comments
 (0)