It is currently April 27th, 2024, 4:27 pm

CPU usage of processes

Get help with creating, editing & fixing problems with skins
User avatar
Jose Hidalgo
Posts: 60
Joined: September 7th, 2018, 4:47 pm

Re: CPU usage of processes

Post by Jose Hidalgo »

OK, for the moment I have added the two relevant lines and it seems to work:

Code: Select all

[MeasureCPU]
Measure=Calc
Formula=MeasureCPUStringAndNumber
MinValue=0
MaxValue=100
What I don't get is why MeasureCPU (well, MeasureCPUStringAndNumber) might produce values larger than 100. And if so, what is the maximum value that it can produce. Care to explain?

For example, for the RAM bar, there is this code:

Code: Select all

MaxValue=[MeasureRAMTotal]
With MeasureRAMTotal having

Code: Select all

Measure=PhysicalMemory
Which makes complete sense.
But what would be the equivalent for MeasureCPU?
Last edited by Jose Hidalgo on February 8th, 2024, 6:36 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16177
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: CPU usage of processes

Post by balala »

Jose Hidalgo wrote: February 8th, 2024, 4:54 pm The code works perfectly, but it displays about 8 times less % than the Task Manager.
I'm on Win 11 Pro 23H2 too.
:o You are perfectly right. :o There is indeed a great difference between what Rainmeter shows and what can be seen in the Task Manager. Didn't notice this so far (switched to Win 11 only a week ago).
As Yincognito mentioned above, SilverAzide added an explanation a while ago, which I read then, but being on Windows 10, I didn't pay too much attention (was not my case at the moment). So I'll have to look for SilverAzide's explanation and read it, to see what can be done.
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: CPU usage of processes

Post by Yincognito »

Jose Hidalgo wrote: February 8th, 2024, 6:33 pm What I don't get is why MeasureCPU (well, MeasureCPUStringAndNumber) might produce values larger than 100. And if so, what is the maximum value that it can produce. Care to explain?
This is related to how the various Windows Performance Monitor counters (where the measure gets its data from) compute the values that the regular user calls "cpu usage". See:
https://techcommunity.microsoft.com/t5/ask-the-performance-team/windows-performance-monitor-overview/ba-p/375481
https://learn.microsoft.com/en-us/troubleshoot/windows-client/performance/cpu-usage-exceeds-100

The short version of it is that the maximum will depend on the hardware you have (e.g. processor features, number of cores, possible overclocking, the percent of the base frequency at which your processor and "cores" run at the moment of data retrieval, , etc). How that computation is done is something Microsoft knows, and it's not a fixed value.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Jose Hidalgo
Posts: 60
Joined: September 7th, 2018, 4:47 pm

Re: CPU usage of processes

Post by Jose Hidalgo »

Wow, I'm starting to get it. So it can go way over 100%, it all depends on the CPU and its boost abilities.

So I guess it's impossible to determine the MaxValue for sure. But here's an idea:
  1. Set a MaxValue that's too high on purpose (200)
  2. Run a torture test like Prime95 that's sure to put the CPU to 100% of its capacity
  3. Note the CPU% displayed by the skin
  4. Multiply it by 2 and change the MaxValue accordingly
E.g. if the CPU% during the stress test is 70% and the MaxValue is 200, then I should set the MaxValue to 140. Am I right? :oops:
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: CPU usage of processes

Post by Yincognito »

Jose Hidalgo wrote: February 8th, 2024, 8:39 pm Wow, I'm starting to get it. So it can go way over 100%, it all depends on the CPU and its boost abilities.

So I guess it's impossible to determine the MaxValue for sure. But here's an idea:
  1. Set a MaxValue that's too high on purpose (200)
  2. Run a torture test like Prime95 that's sure to put the CPU to 100% of its capacity
  3. Note the CPU% displayed by the skin
  4. Multiply it by 2 and change the MaxValue accordingly
E.g. if the CPU% during the stress test is 70% and the MaxValue is 200, then I should set the MaxValue to 140. Am I right? :oops:
The MaxValue you set on the measure doesn't change the value of the measure itself - in other words, it won't "scale" the measure value according to its MaxValue like you think. Plus, the MaxValue is only relevant when it comes to meters that use percentual values (like the Bar meter, for example). But I guess one could do the stress test and note the maximum numerical CPU% value and then set the MaxValue in that measure to it, yes. Or, one could avoid the stress test, keep MaxValue at 100, and either display the numerical value somewhere near the bar (so, even if the bar would be 100% full for an usage of 125%, you'd still have the number displayed to know that is over 100%), or "clamp" the measure value between 0 and 100 so that it never goes past MaxValue (in this case, even if you'd have an usage of 125%, both the numerical value of the measure and the bar filling percentage would not be greater than 100). It depends on how and what you want the skin to display, really - there isn't a "set in stone" system since user preferences will probably be different here.

Clamp reference: https://docs.rainmeter.net/manual/formulas/#Functions (so Formula=(Clamp(MeasureCPUStringAndNumber,0,100)) in your MeasureCPU)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Jose Hidalgo
Posts: 60
Joined: September 7th, 2018, 4:47 pm

Re: CPU usage of processes

Post by Jose Hidalgo »

OK, I get it :) So I guess I'll just leave things as they are for the moment, no need for a stress test. If someday I see my CPU% going over 100%, I'll just take note of the highest value and I'll increase MaxValue accordingly. That should do the trick. ;-)

Thanks for your help!
User avatar
SilverAzide
Rainmeter Sage
Posts: 2612
Joined: March 23rd, 2015, 5:26 pm

Re: CPU usage of processes

Post by SilverAzide »

Jose Hidalgo wrote: February 8th, 2024, 10:42 pm OK, I get it :) So I guess I'll just leave things as they are for the moment, no need for a stress test. If someday I see my CPU% going over 100%, I'll just take note of the highest value and I'll increase MaxValue accordingly. That should do the trick. ;-)

Thanks for your help!
Erm, I'm not sure that logic works. Trying to finagle some number by multiplying things around isn't going to get you anything meaningful, especially if you have an Intel hybrid CPU.

If you are of the mind set (like many folks are) that your CPU usage shouldn't exceed 100%, then you must use the time-based performance counters. The problem is that MS "broke" the time-based counters in Win11 22H2 and at this point it looks like they have no intention of fixing the problem.

You do have a work-around. ;-)
HWiNFO v7.46 and later implements a correction to the time-based counters. So instead of using the Rainmeter's CPU or UsageMonitor measures, use HWiNFO to get this data. Just be aware that Task Manager doesn't use time-based counters (and hasn't since Win8) so what you see there won't match what HWiNFO (or Windows PerfMon) will give you.
Gadgets Wiki GitHub More Gadgets...
User avatar
Jose Hidalgo
Posts: 60
Joined: September 7th, 2018, 4:47 pm

Re: CPU usage of processes

Post by Jose Hidalgo »

SilverAzide wrote: February 9th, 2024, 12:22 amisn't going to get you anything meaningful
It looks good enough for me for the moment, and close enough to the Task Manager.
SilverAzide wrote: February 9th, 2024, 12:22 amespecially if you have an Intel hybrid CPU.
Like I said, I have a Ryzen 7700.
SilverAzide wrote: February 9th, 2024, 12:22 amIf you are of the mind set (like many folks are) that your CPU usage shouldn't exceed 100%
I am indeed. Maybe I am too narrow-minded, but to me a CPU usage is something that can go from 0% to 100%, period.
SilverAzide wrote: February 9th, 2024, 12:22 amHWiNFO v7.46 and later implements a correction to the time-based counters. So instead of using the Rainmeter's CPU or UsageMonitor measures, use HWiNFO to get this data
I'd be happy to do that. I have even found the guide: https://docs.rainmeter.net/tips/hwinfo/
But it looks a bit complicated for my own skills (and possibly a bit overkill too).
I think I'll stay with the current method, at least for the moment. ;-)
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: CPU usage of processes

Post by Yincognito »

Slightly off topic, but anyway...
Jose Hidalgo wrote: February 9th, 2024, 2:40 amLike I said, I have a Ryzen 7700.
Just for information purposes, not related to what you or anyone else has (I too have a Ryzen 5600, btw):
https://www.intel.com/content/www/us/en/support/articles/000091896/processors.html
https://www.xda-developers.com/amd-hybrid-cpu-what-it-will-look-like/
Jose Hidalgo wrote: February 9th, 2024, 2:40 amI am indeed. Maybe I am too narrow-minded, but to me a CPU usage is something that can go from 0% to 100%, period.
I don't think it's narrow minded at all, literally everyone thinks so from a mathematical point of view, where 100% is the absolute maximum. The thing is, in the technology field, things change at a fast pace, partly because of various marketing ploys (remember the NNNN+ MHz processor hype in the past, how 6 physical cores were typically branded as having 12 cores, and so on) and partly because the technological advances happen faster than software development and life cycle. If you look at other performance counters, you'll see that there are others that don't adhere to the logical 0% to 100% range as well, and this will probably continue for the foreseeable future, with more joining this camp.

In a way, it's like trying to establish the "100%" of your broadband / internet speed - it will always be an estimate, with the possibility of having larger speeds than the one time detected "100%". Add to that Microsoft's habit of patching things up instead of reworking them properly from the ground up since they are themselves in a race to make their OS work on a ton of different devices and configurations, and the fact that the "cpu usage" itself is an estimate subject to various subjective conventions and assumptions, and you'll probably conclude that this trend will continue and become the norm. Even if strictly speaking, it may seem illogical. As a fun comparison, it's the same in flight, where you have Mach 2, Mach 3 and so on, corresponding to 200%, 300% and more the speed of sound, and I'm pretty sure that at some point it will be the case with the speed of light as well.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
SilverAzide
Rainmeter Sage
Posts: 2612
Joined: March 23rd, 2015, 5:26 pm

Re: CPU usage of processes

Post by SilverAzide »

Jose Hidalgo wrote: February 9th, 2024, 2:40 am I am indeed. Maybe I am too narrow-minded, but to me a CPU usage is something that can go from 0% to 100%, period.
Oh? Hm. So perhaps you can answer this... My CPU cores can run anywhere from 800MHz to 5 GHz. Say my cores are running at 800Mhz and are 100% busy. Are you saying my CPU usage is at 100%? What's my CPU usage when the cores are running at 5GHz and 100% busy? Also 100%?

This is why MS created "utility" counters back in Win8 days, and they appear to have lost interest in time-based counters.... time-based counters don't really tell you anything about how much actual processing the CPU is doing.
Gadgets Wiki GitHub More Gadgets...