0

How to get current CPU clock speed the same as in Task Manager? WMI CurrentClockSpeed returns the value that is less or equal than MaxClockSpeed and not exactly the same as Task Manager's clock speed.

Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
Spirosi
  • 324
  • 1
  • 15
  • 1
    If you poll fast enough, you'll find that the CPU is either 100% in use or idle. Task Manager polls on a specific interval, and returns the average during that period. – Scott Jan 29 '20 at 15:10
  • @Scott that's another good point... the act of simply polling the value will effect the value. – rfmodulator Jan 29 '20 at 15:15
  • @PanagiotisKanavos I was going to edit to say "may" instead of "will".. but I'll let it stand... This hypothetical is regarding Scott's "If you poll fast enough" – rfmodulator Jan 29 '20 at 15:23

2 Answers2

2

It's coming from the PerformanceCounter by importing the System.Diagnostics module. Please refer to the link for the code example. Just change the parameter to get the value from "Processor Information", "% Processor Performance" and then calculate the CPU frequency by the equation CPU Frequency = "% Processor Performance" * Processor base Frequency. You could use the Windows build-in application "Performance Monitor" to check more PerformanceCounter indexes to find what you want.

John Lin
  • 21
  • 2
1

Because the clock speed changes so frequently, much quicker than Task Manager is updating, you're unlikely to ever get the same value.

rfmodulator
  • 3,638
  • 3
  • 18
  • 22
  • 1
    But why WMI clockspeed doesn't get higher than max speed? In TaskManager you can see that in high performance mode it gets higher – Spirosi Jan 29 '20 at 15:56
  • @Spirosi I'm not certain of the reason, but I was able to find this for you to try... https://stackoverflow.com/a/57873417/1048799 – rfmodulator Jan 29 '20 at 16:49