Benchmarkdotnet: Improve CPU Brand Strings without frequency

Created on 14 Oct 2018  路  7Comments  路  Source: dotnet/BenchmarkDotNet

Here is an example of BenchmarkDotNet output for AMD Ryzen 7 2700X (see https://github.com/spring-projects/spring-net/pull/161):

BenchmarkDotNet=v0.11.1, OS=Windows 10.0.17763
AMD Ryzen 7 2700X Eight-Core Processor (Max: 4.10GHz), 1 CPU, 16 logical and 8 physical cores
.NET Core SDK=2.1.403
  [Host]    : .NET Core 2.1.5 (CoreCLR 4.6.26919.02, CoreFX 4.6.26919.02), 64bit RyuJIT
  MediumRun : .NET Core 2.1.5 (CoreCLR 4.6.26919.02, CoreFX 4.6.26919.02), 64bit RyuJIT

It's great that we are printing the frequency now. However, this line is too huge (93 characters). I don't think that it makes sense to display (Max: since we don't have a nominal frequency in the original string. Also, we can remove Eight-Core Processor because we print 8 physical cores. I guess, we can rewrite it in the following form:

AMD Ryzen 7 2700X 4.10GHz, 1 CPU, 16 logical and 8 physical cores

@Rizzen, @lahma, what do you think?

Most helpful comment

Tested and this kind of crude cleanup routine would strip away the repetition:

var cleanedProcessorModelNames = new List<string>(processorModelNames);
for (int i = 0; i < cleanedProcessorModelNames.Count; i++)
{
    string modelName = cleanedProcessorModelNames[i];
    var matches = Regex.Matches(modelName, @"((\w|\d)+?-Core Processor)");
    if (physicalCoreCount > 0
        && logicalCoreCount > 0
        && matches.Count > 0)
    {
        cleanedProcessorModelNames[i] = modelName.Replace(matches[0].Groups[1].Value, "").Trim();
    }
}

So when cores and logical processors are detected, matching extra info could be stripped at least in this AMD case.

All 7 comments

I think that's makes sense, but there is a question - how to detect parts of processor brand string like "Eight-Core Processor" in smart way.

I guess, we can start with a dumb way and handle known brand strings with the help of simple heuristics.

Yes, it's a bit long. I actually was more missing the actual GHz information that seems to resolve to Unknown timer in Chronometer (freqKHz == 10000). That would explain more as you can always overclock etc. Though again that is also unreliable if CPU uses C states / boost technology or whatever and adjusts the frequency during tests (related to https://github.com/dotnet/BenchmarkDotNet/issues/68).

Here's the part that doesn't detect on AMD, usually I've done my testing on Intel before.

https://github.com/dotnet/BenchmarkDotNet/blob/c3b6095b933b132c1773ced3af126f282465b980/src/BenchmarkDotNet/Horology/Chronometer.cs#L29-L43

For me AMD Ryzen 7 2700X is enough as I can always google what's inside my case 馃槃

as I can always google what's inside my case

@lahma we are trying to provide as much useful information as we can in the most compact form. It helps people who are reading your performance report to instantly understand your hardware configuration without additional googling.

Tested and this kind of crude cleanup routine would strip away the repetition:

var cleanedProcessorModelNames = new List<string>(processorModelNames);
for (int i = 0; i < cleanedProcessorModelNames.Count; i++)
{
    string modelName = cleanedProcessorModelNames[i];
    var matches = Regex.Matches(modelName, @"((\w|\d)+?-Core Processor)");
    if (physicalCoreCount > 0
        && logicalCoreCount > 0
        && matches.Count > 0)
    {
        cleanedProcessorModelNames[i] = modelName.Replace(matches[0].Groups[1].Value, "").Trim();
    }
}

So when cores and logical processors are detected, matching extra info could be stripped at least in this AMD case.

Was this page helpful?
0 / 5 - 0 ratings