Skip to content

Commit ae4bb9b

Browse files
Bump Perfolizer + Initial Phd adoption
This commit is a first step of the grand API refactoring. * Cpu Detection Upgrade * All CPU-related detection logic moved from RuntimeInformation to CpuDetector * BrandString formatting moved to Perfolizer (see CpuBrandHelper) * New serializable class for Cpu information: PhdCpu from Perfolizer * Os Detection Upgrade * All OS-related detection logic moved from RuntimeInformation to OsDetector * BrandString formatting moved to Perfolizer (see OsBrandHelper) * New serializable class for Os information: PhdOs from Perfolizer * Initial adoption of Phd (Performance History Data) * Phd from Perfolizer is our future way to keep and process gathered data and measurements * Only the initial implementation is available, it still misses a lot of features * Examples of Phd json and corresponding new Summary Tables are in BenchmarkDotNet/tests/BenchmarkDotNet.Tests/Phd/VerifiedFiles/Phd.PhdTableTest* * Phd can be tried via [PhdExporter] * Documentation is coming once we have a more complete implementation
1 parent a58872b commit ae4bb9b

File tree

133 files changed

+8619
-1393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+8619
-1393
lines changed

src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using BenchmarkDotNet.Detectors;
45
using BenchmarkDotNet.Diagnosers;
56
using BenchmarkDotNet.Portability;
67
using BenchmarkDotNet.Toolchains.InProcess.Emit;
@@ -31,7 +32,7 @@ private static readonly Dictionary<HardwareCounter, string> EtwTranslations
3132

3233
public static IEnumerable<ValidationError> Validate(ValidationParameters validationParameters, bool mandatory)
3334
{
34-
if (!RuntimeInformation.IsWindows())
35+
if (!OsDetector.IsWindows())
3536
{
3637
yield return new ValidationError(true, "Hardware Counters and EtwProfiler are supported only on Windows");
3738
yield break;

src/BenchmarkDotNet.Diagnostics.Windows/JitDiagnoser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using BenchmarkDotNet.Detectors;
34
using BenchmarkDotNet.Diagnosers;
45
using BenchmarkDotNet.Engines;
56
using BenchmarkDotNet.Loggers;
@@ -33,7 +34,7 @@ public void Handle(HostSignal signal, DiagnoserActionParameters parameters)
3334

3435
public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters)
3536
{
36-
if (!RuntimeInformation.IsWindows())
37+
if (!OsDetector.IsWindows())
3738
{
3839
yield return new ValidationError(true, $"{GetType().Name} is supported only on Windows");
3940
}

src/BenchmarkDotNet.Diagnostics.dotMemory/DotMemoryDiagnoser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using System.Collections.Immutable;
44
using System.Linq;
55
using BenchmarkDotNet.Analysers;
6+
using BenchmarkDotNet.Detectors;
67
using BenchmarkDotNet.Diagnosers;
78
using BenchmarkDotNet.Engines;
89
using BenchmarkDotNet.Exporters;
910
using BenchmarkDotNet.Jobs;
1011
using BenchmarkDotNet.Loggers;
11-
using BenchmarkDotNet.Portability;
1212
using BenchmarkDotNet.Reports;
1313
using BenchmarkDotNet.Running;
1414
using BenchmarkDotNet.Validators;
@@ -124,10 +124,10 @@ internal static bool IsSupported(RuntimeMoniker runtimeMoniker)
124124
case RuntimeMoniker.NetCoreApp20:
125125
case RuntimeMoniker.NetCoreApp21:
126126
case RuntimeMoniker.NetCoreApp22:
127-
return RuntimeInformation.IsWindows();
127+
return OsDetector.IsWindows();
128128
case RuntimeMoniker.NetCoreApp30:
129129
case RuntimeMoniker.NetCoreApp31:
130-
return RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux();
130+
return OsDetector.IsWindows() || OsDetector.IsLinux();
131131
default:
132132
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, $"Runtime moniker {runtimeMoniker} is not supported");
133133
}

src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using System.Collections.Immutable;
44
using System.Linq;
55
using BenchmarkDotNet.Analysers;
6+
using BenchmarkDotNet.Detectors;
67
using BenchmarkDotNet.Diagnosers;
78
using BenchmarkDotNet.Engines;
89
using BenchmarkDotNet.Exporters;
910
using BenchmarkDotNet.Jobs;
1011
using BenchmarkDotNet.Loggers;
11-
using BenchmarkDotNet.Portability;
1212
using BenchmarkDotNet.Reports;
1313
using BenchmarkDotNet.Running;
1414
using BenchmarkDotNet.Toolchains;
@@ -118,10 +118,10 @@ internal static bool IsSupported(RuntimeMoniker runtimeMoniker)
118118
case RuntimeMoniker.NetCoreApp20:
119119
case RuntimeMoniker.NetCoreApp21:
120120
case RuntimeMoniker.NetCoreApp22:
121-
return RuntimeInformation.IsWindows();
121+
return OsDetector.IsWindows();
122122
case RuntimeMoniker.NetCoreApp30:
123123
case RuntimeMoniker.NetCoreApp31:
124-
return RuntimeInformation.IsWindows() || RuntimeInformation.IsLinux();
124+
return OsDetector.IsWindows() || OsDetector.IsLinux();
125125
default:
126126
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, $"Runtime moniker {runtimeMoniker} is not supported");
127127
}

src/BenchmarkDotNet/Analysers/ZeroMeasurementAnalyser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private ZeroMeasurementAnalyser() { }
1919

2020
protected override IEnumerable<Conclusion> AnalyseReport(BenchmarkReport report, Summary summary)
2121
{
22-
var currentFrequency = summary.HostEnvironmentInfo.CpuInfo.Value.MaxFrequency;
22+
var currentFrequency = summary.HostEnvironmentInfo.Cpu.Value.MaxFrequency();
2323
if (!currentFrequency.HasValue || currentFrequency <= 0)
2424
currentFrequency = FallbackCpuResolutionValue.ToFrequency();
2525

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using BenchmarkDotNet.Exporters;
3+
4+
namespace BenchmarkDotNet.Attributes;
5+
6+
/// <summary>
7+
/// IMPORTANT: Not fully implemented yet
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
10+
public class PhdExporterAttribute() : ExporterConfigBaseAttribute(new PhdJsonExporter(), new PhdMdExporter());

src/BenchmarkDotNet/BenchmarkDotNet.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
</PropertyGroup>
1414
<ItemGroup>
1515
<EmbeddedResource Include="Templates\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
16-
<EmbeddedResource Include="Environments\microarchitectures.txt" />
1716
</ItemGroup>
1817
<ItemGroup>
1918
<PackageReference Include="CommandLineParser" Version="2.9.1" />
2019
<PackageReference Include="Gee.External.Capstone" Version="2.3.0" />
2120
<PackageReference Include="Iced" Version="1.17.0" />
2221
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="2.2.332302" />
23-
<PackageReference Include="Perfolizer" Version="[0.3.17]" />
22+
<PackageReference Include="Perfolizer" Version="[0.4.0]" />
2423
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.8" PrivateAssets="contentfiles;analyzers" />
2524
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
2625
<!-- Do not update these packages, or else netcoreapp3.0 and older will no longer work -->

src/BenchmarkDotNet/Configs/DefaultConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using BenchmarkDotNet.Analysers;
66
using BenchmarkDotNet.Columns;
7+
using BenchmarkDotNet.Detectors;
78
using BenchmarkDotNet.Diagnosers;
89
using BenchmarkDotNet.EventProcessors;
910
using BenchmarkDotNet.Exporters;
@@ -90,7 +91,7 @@ public string ArtifactsPath
9091
{
9192
get
9293
{
93-
var root = RuntimeInformation.IsAndroid() ?
94+
var root = OsDetector.IsAndroid() ?
9495
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) :
9596
Directory.GetCurrentDirectory();
9697
return Path.Combine(root, "BenchmarkDotNet.Artifacts");

src/BenchmarkDotNet/Portability/Cpu/HardwareIntrinsics.cs renamed to src/BenchmarkDotNet/Detectors/Cpu/HardwareIntrinsics.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
5-
using BenchmarkDotNet.Environments;
65
using System.Text;
7-
6+
using BenchmarkDotNet.Environments;
87
#if NET6_0_OR_GREATER
98
using System.Runtime.Intrinsics.X86;
109
using System.Runtime.Intrinsics.Arm;
1110
#endif
1211

13-
namespace BenchmarkDotNet.Portability.Cpu
12+
namespace BenchmarkDotNet.Detectors.Cpu
1413
{
1514
internal static class HardwareIntrinsics
1615
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Perfolizer.Phd.Dto;
2+
3+
namespace BenchmarkDotNet.Detectors.Cpu;
4+
5+
/// <summary>
6+
/// Loads the <see cref="PhdCpu"/> for the current hardware
7+
/// </summary>
8+
public interface ICpuDetector
9+
{
10+
bool IsApplicable();
11+
PhdCpu? Detect();
12+
}

0 commit comments

Comments
 (0)