dotnet / dotnet/BenchmarkDotNet
Wrong CPU frequency
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 1.1k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 11
Description
I have an Intel 8700K CPU that overclocked to 5.0Ghz with 2x AVX multiplier negative offset (CPU down multiplier from 50 to 48 when execute AVX instructions). So if I run some simple bencmark like this
```csharp
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Exporters;
using BenchmarkDotNet.Running;
namespace Benchmark
{
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run();
}
}
[MarkdownExporter]
public class ArraySum
{
public int[] ArrayOfInts { get; set; }
[Params(1024, 32 * 1024)] public int TestArrayLength { get; set; }
[GlobalSetup]
public void GlobalSetup()
{
ArrayOfInts = Enumerable.Range(0, TestArrayLength).ToArray();
}
[Benchmark]
public float Sum_Simple()
{
return Sum_Simple(ArrayOfInts);
}
public static float Sum_Simple(int[] array)
{
float result = 0;
for (var i = 0; i < array.LongLength; i++)
result += array[i];
return result;
}
}
}
```
I've got the following results
```
BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
Frequency=3609380 Hz, Resolution=277.0559 ns, Timer=TSC
.NET Core SDK=2.1.301
[Host] : .NET Core 2.1.1 (CoreCLR 4.6.26606.02, CoreFX 4.6.26606.05), 64bit RyuJIT
DefaultJob : .NET Core 2.1.1 (CoreCLR 4.6.26606.02, CoreFX 4.6.26606.05), 64bit RyuJIT
Method | TestArrayLength | Mean | Error | StdDev |
----------- |---------------- |------------:|-----------:|-----------:|
Sum_Simple | 1024 | 848.8 ns | 1.308 ns | 1.160 ns |
Sum_Simple | 32768 | 27,250.4 ns | 117.776 ns | 110.168 ns |
```
But the real CPU frequency was between 4.8Ghz and 5.0Ghz.
I've use Windows 10 Pro for Workstations with enabled "Ultimate Perfomance" power profile, that locks CPU frequency on 100%.
It looks like BenchmarkDotNet ignores Turbo-boost.
Contributor guide
Assessment
This issue has not been assessed yet.