It is currently April 25th, 2024, 12:35 pm

how to write loop to calculate cpu average clock speed?

Get help with creating, editing & fixing problems with skins
smokey
Posts: 1
Joined: August 16th, 2019, 12:43 pm

how to write loop to calculate cpu average clock speed?

Post by smokey »

hi guys, i just upgraded to ryzen 8 cores cpu and the existing plugin PowerPlugin MHz doesn't work for me anymore. it is always showing 0 MHz.

so below is the code that i wrote. I utilized HWinfo's sensor and written 8x of the same thing. As you can see, the MeasureCPUClock#, and HWiNFOEntryId=0x600000# have the same pattern, where the last digit indicates the core number. At [MeasureCPUClock_Avg], i added up everything and divided by 8 to get the average cpu speed and this is working fine.

My question is, how do i utilize the LOOP command to simplify this? This is just in case the number of cores grow in the future.

Code: Select all

[MeasureCPUClock0]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000000
HWiNFOType=CurrentValue

[MeasureCPUClock1]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000001
HWiNFOType=CurrentValue

[MeasureCPUClock2]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000002
HWiNFOType=CurrentValue

[MeasureCPUClock3]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000003
HWiNFOType=CurrentValue

[MeasureCPUClock4]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000004
HWiNFOType=CurrentValue

[MeasureCPUClock5]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000005
HWiNFOType=CurrentValue

[MeasureCPUClock6]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000006
HWiNFOType=CurrentValue

[MeasureCPUClock7]
Measure=Plugin
Plugin=HWiNFO
HWiNFOSensorId=0xf0000300
HWiNFOSensorInstance=0x0
HWiNFOEntryId=0x6000007
HWiNFOType=CurrentValue

[MeasureCPUClock_Avg]
Measure=Calc
Formula=(MeasureCPUClock0+MeasureCPUClock1+MeasureCPUClock2+MeasureCPUClock3+MeasureCPUClock4+MeasureCPUClock5+MeasureCPUClock6+MeasureCPUClock7)/8

[MeterLabelCPUClock]
Meter=STRING
MeasureName=MeasureCPUClock_Avg
MeterStyle=styleCenterText
X=102
Y=20r
W=130
H=14
Text="Clock Speed: %1 MHz"
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: how to write loop to calculate cpu average clock speed?

Post by jsmorley »

I'm not sure there is a good way to do this. You have to hard-code the number of HWiNFO measures needed to get the maximum number of cores, and even if you hard-code say 32 of them to account for some extreme CPU, I don't see a way to dynamically alter the formula, which as you note must be ((core0+core1+core2)/numOfCores). I don't see any way the Loop measure can play a roll in this. Plus, the user would still have to alter the sensor values for HWiNFO to match their system.

I think you might just look at creating "variants" of the skin, with say 4-8-16-32 cores supported in them.