C #: how to get the current Intel i-series processor clock speed when TurboBoost is activated

I know that it is possible to get this information. Intel TurboBoost's built-in Sidebar gadget seems to use an ActiveX control to determine the current clock speed of the i3 / i5 / i7 processor when TurboBoost is active. However, I want to do this programmatically in C # - getting the CurrentClockSpeed ​​value from WMI ends with the set maximum CPU clock speed, therefore, in TurboBoost mode, it does not report the current actual clock frequency.

+5
source share
3 answers

I don't find it possible to get this information only with safe / managed C # code, since WMI does not seem to provide this information. Therefore, I think you will need to use the CPUID instruction to get detailed information from the processor that executes the instruction.

This Intel documentation can help you get started:

http://www.intel.com/assets/pdf/appnote/241618.pdf

And here is some unsafe code to use with C #:

Trying to cast CPUID to C #

Also see page 7 of:

Intel® Turbo Boost Technology on Intel® Core ™ Microarchitecture (Nehalem) Processors

+2
source

If you want to get turbo speed, you can use the performance counter "% CPU performance" and multiply it by WMI "MaxClockSpeed" as follows:

private string GetCPUInfo()
{
  PerformanceCounter cpuCounter = new PerformanceCounter("Processor Information", "% Processor Performance", "_Total");
  double cpuValue = cpuCounter.NextValue();

  Thread loop = new Thread(() => InfiniteLoop());
  loop.Start();

  Thread.Sleep(1000);
  cpuValue = cpuCounter.NextValue();
  loop.Abort();

  foreach (ManagementObject obj in new ManagementObjectSearcher("SELECT *, Name FROM Win32_Processor").Get())
  {
    double maxSpeed = Convert.ToDouble(obj["MaxClockSpeed"]) / 1000;
    double turboSpeed = maxSpeed * cpuValue / 100;
    return string.Format("{0} Running at {1:0.00}Ghz, Turbo Speed: {2:0.00}Ghz",  obj["Name"], maxSpeed, turboSpeed);
  }

  return string.Empty;
}

InfiniteLoop - , 1:

private void InfiniteLoop()
{
  int i = 0;

  while (true)
    i = i + 1 - 1;
}

InfiniteLoop , - . , .

.

0

All Articles