Skip to content

Commit 2c99d26

Browse files
committed
Add implicitId characteristics
1 parent 6f5ebe6 commit 2c99d26

16 files changed

+183
-129
lines changed

src/BenchmarkDotNet/Attributes/Jobs/JobConfigbaseAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class JobConfigBaseAttribute : Attribute, IConfigSource
2121
protected static Job GetJob(Job sourceJob, RuntimeMoniker runtimeMoniker, Jit? jit, Platform? platform)
2222
{
2323
var runtime = runtimeMoniker.GetRuntime();
24-
var baseJob = sourceJob.WithRuntime(runtime).WithId($"{sourceJob.Id}-{runtime.Name}");
25-
var id = baseJob.Id;
24+
var baseJob = sourceJob.WithRuntime(runtime);
25+
var id = $"{sourceJob.Id}-{runtime.Name}";
2626

2727
if (jit.HasValue)
2828
{
@@ -36,7 +36,7 @@ protected static Job GetJob(Job sourceJob, RuntimeMoniker runtimeMoniker, Jit? j
3636
id += "-" + platform.Value;
3737
}
3838

39-
return baseJob.WithId(id).Freeze();
39+
return baseJob.WithImplicitId(id).Freeze();
4040
}
4141
}
4242
}

src/BenchmarkDotNet/Attributes/Jobs/SimpleJobAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static Job CreateJob(string id, int launchCount, int warmupCount, int it
108108
}
109109

110110
if (id == null && manualValuesCount == 1 && runtimeMoniker != RuntimeMoniker.HostProcess)
111-
job = job.WithId(runtimeMoniker.GetRuntime().Name);
111+
job = job.WithImplicitId(runtimeMoniker.GetRuntime().Name);
112112

113113
return job.Freeze();
114114
}

src/BenchmarkDotNet/Columns/JobCharacteristicColumn.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
using System.Linq;
33
using BenchmarkDotNet.Characteristics;
44
using BenchmarkDotNet.Environments;
5+
using BenchmarkDotNet.Extensions;
56
using BenchmarkDotNet.Jobs;
67
using BenchmarkDotNet.Reports;
78
using BenchmarkDotNet.Running;
8-
using BenchmarkDotNet.Toolchains;
99

1010
namespace BenchmarkDotNet.Columns
1111
{
@@ -43,15 +43,20 @@ public bool IsAvailable(Summary summary)
4343
switch (ColumnName)
4444
{
4545
case Column.Job:
46-
return false;
46+
return summary.BenchmarksCases
47+
.Any(b => b.Job.HasValue(Job.IdCharacteristic) && !b.Job.GetValue(Job.ImplicitIdCharacteristic));
4748
case Column.Toolchain:
48-
var groups = summary.BenchmarksCases.GroupBy(b => b.GetRuntime(), b => b.GetToolchain().Name).ToArray();
4949

50-
bool isOneRuntime = groups.Length <= 1;
51-
if (isOneRuntime)
50+
var toolchainsByRuntime = summary.BenchmarksCases
51+
.GroupBy(b => b.GetRuntime().Name, b => b.Job.GetValue(InfrastructureMode.ToolchainCharacteristic))
52+
.ToArray();
53+
54+
if (toolchainsByRuntime.Length <= 1)
5255
return true;
5356

54-
return groups.Any(toolchainNames => toolchainNames.Distinct().Count() > 1);
57+
return toolchainsByRuntime.Any(toolchains => toolchains.Where(toolchain => toolchain != null)
58+
.DistinctBy(toolchain => toolchain.Name)
59+
.Count() > 1);
5560
default:
5661
return true;
5762
}

src/BenchmarkDotNet/Jobs/Job.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@ public sealed class Job : JobMode<Job>
1414
[PublicAPI] public static readonly Characteristic<AccuracyMode> AccuracyCharacteristic = CreateCharacteristic<AccuracyMode>(nameof(Accuracy));
1515
[PublicAPI] public static readonly Characteristic<MetaMode> MetaCharacteristic = CreateCharacteristic<MetaMode>(nameof(Meta));
1616

17-
public static readonly Job LegacyJitX86 = new Job(nameof(LegacyJitX86), EnvironmentMode.LegacyJitX86).Freeze();
18-
public static readonly Job LegacyJitX64 = new Job(nameof(LegacyJitX64), EnvironmentMode.LegacyJitX64).Freeze();
19-
public static readonly Job RyuJitX64 = new Job(nameof(RyuJitX64), EnvironmentMode.RyuJitX64).Freeze();
20-
public static readonly Job RyuJitX86 = new Job(nameof(RyuJitX86), EnvironmentMode.RyuJitX86).Freeze();
17+
internal static readonly Characteristic<bool> ImplicitIdCharacteristic = CreateHiddenCharacteristic<bool>("ImplicitId");
18+
19+
public static readonly Job LegacyJitX86 = new Job(EnvironmentMode.LegacyJitX86).WithImplicitId(nameof(LegacyJitX86)).Freeze();
20+
public static readonly Job LegacyJitX64 = new Job(EnvironmentMode.LegacyJitX64).WithImplicitId(nameof(LegacyJitX64)).Freeze();
21+
public static readonly Job RyuJitX64 = new Job(EnvironmentMode.RyuJitX64).WithImplicitId(nameof(RyuJitX64)).Freeze();
22+
public static readonly Job RyuJitX86 = new Job(EnvironmentMode.RyuJitX86).WithImplicitId(nameof(RyuJitX86)).Freeze();
2123

2224
// Run
23-
public static readonly Job Dry = new Job(nameof(Dry), RunMode.Dry).Freeze();
25+
public static readonly Job Dry = new Job(RunMode.Dry).WithImplicitId(nameof(Dry)).Freeze();
2426

25-
public static readonly Job ShortRun = new Job(nameof(ShortRun), RunMode.Short).Freeze();
26-
public static readonly Job MediumRun = new Job(nameof(MediumRun), RunMode.Medium).Freeze();
27-
public static readonly Job LongRun = new Job(nameof(LongRun), RunMode.Long).Freeze();
28-
public static readonly Job VeryLongRun = new Job(nameof(VeryLongRun), RunMode.VeryLong).Freeze();
27+
public static readonly Job ShortRun = new Job(RunMode.Short).WithImplicitId(nameof(ShortRun)).Freeze();
28+
public static readonly Job MediumRun = new Job(RunMode.Medium).WithImplicitId(nameof(MediumRun)).Freeze();
29+
public static readonly Job LongRun = new Job(RunMode.Long).WithImplicitId(nameof(LongRun)).Freeze();
30+
public static readonly Job VeryLongRun = new Job(RunMode.VeryLong).WithImplicitId(nameof(VeryLongRun)).Freeze();
2931

3032
// Infrastructure
31-
public static readonly Job InProcess = new Job(nameof(InProcess), InfrastructureMode.InProcess);
32-
public static readonly Job InProcessDontLogOutput = new Job(nameof(InProcessDontLogOutput), InfrastructureMode.InProcessDontLogOutput);
33+
public static readonly Job InProcess = new Job(InfrastructureMode.InProcess).WithImplicitId(nameof(InProcess));
34+
public static readonly Job InProcessDontLogOutput = new Job(InfrastructureMode.InProcessDontLogOutput).WithImplicitId(nameof(InProcessDontLogOutput));
3335

3436
public Job() : this((string)null) { }
3537

@@ -40,6 +42,7 @@ public Job(string id) : base(id)
4042
InfrastructureCharacteristic[this] = new InfrastructureMode();
4143
AccuracyCharacteristic[this] = new AccuracyMode();
4244
MetaCharacteristic[this] = new MetaMode();
45+
ImplicitIdCharacteristic[this] = false;
4346
}
4447

4548
public Job(CharacteristicObject other) : this((string)null, other)

src/BenchmarkDotNet/Jobs/JobExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public static class JobExtensions
2121
public static Job With(this Job job, Platform platform) => job.WithPlatform(platform);
2222
public static Job WithPlatform(this Job job, Platform platform) => job.WithCore(j => j.Environment.Platform = platform);
2323

24-
public static Job WithId(this Job job, string id) => new Job(id, job);
24+
public static Job WithId(this Job job, string id) => new Job(id, job).WithImplicitId(false);
25+
26+
internal static Job WithImplicitId(this Job job, string id) => new Job(id, job).WithImplicitId(true);
27+
private static Job WithImplicitId(this Job job, bool isImplicit) => job.WithCore(j => Job.ImplicitIdCharacteristic[j] = isImplicit);
2528

2629
// Env
2730
[EditorBrowsable(EditorBrowsableState.Never)]

src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMToolChain.cs renamed to src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMToolchain.cs

File renamed without changes.

tests/BenchmarkDotNet.Tests/Columns/ApprovedFiles/JobColumnsApprovalTests.ColumnsDisplayTest.net7-net6-net6.approved.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/BenchmarkDotNet.Tests/Columns/ApprovedFiles/JobColumnsApprovalTests.ColumnsDisplayTest.net7.approved.txt renamed to tests/BenchmarkDotNet.Tests/Columns/ApprovedFiles/JobColumnsApprovalTests.ExplicitIdsAreDiscovered.approved.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
=== net7 ===
2-
1+

32
BenchmarkDotNet=v0.10.x-mock, OS=Microsoft Windows NT 10.0.x.mock, VM=Hyper-V
43
MockIntel Core i7-6700HQ CPU 2.60GHz (Max: 3.10GHz), 1 CPU, 8 logical and 4 physical cores
54
Frequency=2531248 Hz, Resolution=395.0620 ns, Timer=TSC
65
[Host] : Clr 4.0.x.mock, 64mock RyuJIT-v4.6.x.mock CONFIGURATION
7-
net7 : extra output line
6+
Dry : extra output line
87

9-
Runtime=.NET 7.0 IterationCount=1 LaunchCount=1
8+
Job=Dry IterationCount=1 LaunchCount=1
109
RunStrategy=ColdStart UnrollFactor=1 WarmupCount=1
1110

1211
Method | Mean | Error |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+

2+
BenchmarkDotNet=v0.10.x-mock, OS=Microsoft Windows NT 10.0.x.mock, VM=Hyper-V
3+
MockIntel Core i7-6700HQ CPU 2.60GHz (Max: 3.10GHz), 1 CPU, 8 logical and 4 physical cores
4+
Frequency=2531248 Hz, Resolution=395.0620 ns, Timer=TSC
5+
[Host] : Clr 4.0.x.mock, 64mock RyuJIT-v4.6.x.mock CONFIGURATION
6+
Dry : extra output line
7+
8+
IterationCount=1 LaunchCount=1 RunStrategy=ColdStart
9+
UnrollFactor=1 WarmupCount=1
10+
11+
Method | Mean | Error |
12+
------- |---------:|------:|
13+
Method | 1.000 ns | NA |

tests/BenchmarkDotNet.Tests/Columns/ApprovedFiles/JobColumnsApprovalTests.MultipleInputColumnsDisplayTest.MultipleInputColumnsDisplayTest.approved.txt renamed to tests/BenchmarkDotNet.Tests/Columns/ApprovedFiles/JobColumnsApprovalTests.MultipleInputJobsAreDiscovered.approved.txt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
=== MultipleInputColumnsDisplayTest ===
2-
1+

32
BenchmarkDotNet=v0.10.x-mock, OS=Microsoft Windows NT 10.0.x.mock, VM=Hyper-V
43
MockIntel Core i7-6700HQ CPU 2.60GHz (Max: 3.10GHz), 1 CPU, 8 logical and 4 physical cores
54
Frequency=2531248 Hz, Resolution=395.0620 ns, Timer=TSC
6-
[Host] : Clr 4.0.x.mock, 64mock RyuJIT-v4.6.x.mock CONFIGURATION
7-
Job-rndId0 : extra output line
8-
Job-rndId1 : extra output line
9-
Job-rndId2 : extra output line
10-
Job-rndId3 : extra output line
11-
Job-rndId4 : extra output line
12-
Job-rndId5 : extra output line
13-
Dry : extra output line
5+
[Host] : Clr 4.0.x.mock, 64mock RyuJIT-v4.6.x.mock CONFIGURATION
6+
Job-rndId0 : extra output line
7+
Job-rndId1 : extra output line
8+
Job-rndId2 : extra output line
9+
Dry : extra output line
10+
Dry-.NET 6.0 : extra output line
11+
Dry-.NET Framework 4.8.1 : extra output line
12+
Dry-NativeAOT 6.0 : extra output line
1413

1514

1615
Method | Runtime | IterationCount | LaunchCount | RunStrategy | UnrollFactor | WarmupCount | Mean | Error | Ratio |
1716
------- |--------------------- |--------------- |------------ |------------ |------------- |------------ |---------:|------:|------:|
18-
Method | .NET 6.0 | Default | Default | ColdStart | 1 | Default | 1.000 ns | NA | 1.00 |
19-
Method | .NET 6.0 | Default | Default | Default | 16 | Default | 1.000 ns | NA | 1.00 |
20-
Method | .NET Framework 4.8.1 | Default | Default | ColdStart | 1 | Default | 1.000 ns | NA | 1.00 |
17+
Method | .NET 7.0 | Default | Default | Default | 16 | Default | 1.000 ns | NA | 1.00 |
2118
Method | .NET Framework 4.8.1 | Default | Default | Default | 16 | Default | 1.000 ns | NA | 1.00 |
22-
Method | NativeAOT 6.0 | Default | Default | ColdStart | 1 | Default | 1.000 ns | NA | 1.00 |
23-
Method | NativeAOT 6.0 | Default | Default | Default | 16 | Default | 1.000 ns | NA | 1.00 |
19+
Method | NativeAOT 7.0 | Default | Default | Default | 16 | Default | 1.000 ns | NA | 1.00 |
20+
Method | .NET 7.0 | 1 | 1 | ColdStart | 1 | 1 | 1.000 ns | NA | 1.00 |
21+
Method | .NET Framework 4.8.1 | 1 | 1 | ColdStart | 1 | 1 | 1.000 ns | NA | 1.00 |
22+
Method | NativeAOT 7.0 | 1 | 1 | ColdStart | 1 | 1 | 1.000 ns | NA | 1.00 |
2423
Method | .NET 6.0 | 1 | 1 | ColdStart | 1 | 1 | 1.000 ns | NA | 1.00 |
2524
Method | .NET Framework 4.8.1 | 1 | 1 | ColdStart | 1 | 1 | 1.000 ns | NA | 1.00 |
2625
Method | NativeAOT 6.0 | 1 | 1 | ColdStart | 1 | 1 | 1.000 ns | NA | 1.00 |

0 commit comments

Comments
 (0)