Njanderson/resmon

CPU frequency

Closed this issue · 13 comments

  • Thank you very much for your work. Resource Monitor is very good. 👍
  • I have a problem about CPU frequency:

At present, on my computer, CPU frequency shows Base speed(①) instead of speed(②). The value of Base speed will remain unchanged. image

For me, the latter is more important. I'm not sure if this is due to my setting error or if Resource Monitor doesn't support real-time display speed.

批注 2020-01-15 095124

Yes, this should be fixed. Currently resmon uses the si.cpu API, but instead it should use si.cpuCurrentspeed.

On Windows, this also maxes out your CPU. WMIC (where the systeminformation get its CPU clock speed) doesn't have this information. I have spent a long time trying to figure out a real way to get the current CPU clock speed, but it's very hard to do. On my laptop, which has a max freq. of 2.11 Ghz, every field is listed as this clock speed. I'll do some hunting to see if there is something better on Windows in another node module.

On Windows, the WMIC output isn't right:

>wmic path win32_processor get CurrentClockSpeed, MaxClockSpeed, Name
CurrentClockSpeed  MaxClockSpeed  Name
1910               2112           Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz

>wmic cpu get CurrentClockSpeed, MaxClockSpeed, Name
CurrentClockSpeed  MaxClockSpeed  Name
1910               2112           Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz

For example, the NodeJs os.cpus():

> os.cpus()
[
  {
    model: 'Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz',
    speed: 2112,
    times: { user: 630312, nice: 0, sys: 494515, idle: 11524515, irq: 77859 }
  },
  {
    model: 'Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz',
    speed: 2112,
    times: { user: 515890, nice: 0, sys: 227203, idle: 11905750, irq: 6234 }
  },

Looking at other NPM modules, they also do this wrong.

For N=2, my desktop also does this:

> cpuCurrentSpeed
Promise {
  { min: 3.6,
    max: 3.6,
    avg: 3.6,
    cores:
     [ 3.6, 3.6, 3.6, 3.6, 3.6, 3.6, 3.6, 3.6, 3.6, 3.6, 3.6, 3.6 ] },

I've actually invested a ton of time and effort into figuring this out, but I haven't come to a solution that works, not even using C++ and Win32 APIs to measure it in Windows. None of the example programs actually match Task Manager, and I cannot comment on what Task Manager does.

Ah that's a shame, I had no idea the situation was so dire. I think for now then this should be documented, also in the description text of the vs code setting. You can Markdown now, so could even apply some formatting etc.

For Intel processors, you can do something like this extension does, which is read an Intel CPU MSR, which gives the current CPU operating point. But you need go to to Kernel mode just to read this - and this is a VS Code extension, so I abandoned it.

Agreed - I actually think this works okay in Linux.

If someone can comment on whether cpuCurrentspeed (Yes, the capitalization in systeminformation is not quite camel-cased) is required for Linux, I'd appreciate it!

Taking an action item to document this for Windows, and leave Linux/MacOS as is.

For @ZenanH, I'm sorry I couldn't help more on this.

If someone comes up with a solution that works in Windows, I'd love to hear it! 👍

I think we want cpuCurrentspeed, as si.cpu just parses the "Model name:" line of lscpu and doesn't query the current speed, except as fall-back if the number is 0. I'm personally never interested in the static/base cpu speed.

Moving onto cpuCurrentspeed.avg.