LCD-Smartie / LCDSmartie

The New Official LCD Smartie Repository (LCD Smartie Lazarus port)
GNU General Public License v2.0
37 stars 5 forks source link

$SysCPUSpeed - $SysCPUUsage #8

Closed Rei444 closed 1 year ago

Rei444 commented 1 year ago

I use the version: x64-5.5.3.4 My System: Win 11 Pro German [Version 10.0.22621.1555]

Wrong Output image image

HW Monitor Reference: image

rdoursenaud commented 1 year ago

The clock has always been the CPU's base clock. I'd love for it to report the current boost clock too but how do you pick one between the cores? CPU are not monolithic anymore.

For the CPU Usage it's probably due to #3.

stokie-ant commented 1 year ago

I've been working on a new tab and new functions that will allow to display the actual clock speed and usage of each core. Only thing is windows 11 usage will display 100%+ when in boost for example mine shows around 160% the task manager takes this into account probably by calculating the percentage of boost and subtracting it from usage. So the question is boosted percentage or calculated percentage

rdoursenaud commented 1 year ago

HWiNFO64 states that the task manager clamps the data to 100% when going above. I for one would love to see the actual data with the boost part (I.e. above 100%). Maybe allow to retrieve either a capped and uncapped value using a parameter?

Rei444 commented 1 year ago

For me it is OK - the total CPU-Usage (Auslastung) in % and total CPU-Speed (Geschwindigkeit) in GHz. CPU Usage/Speed for each Core and Vcore it's nice but overstyled.

image

stokie-ant commented 1 year ago

New version done. Let me know if it works https://github.com/stokie-ant/lcdsmartie-laz#readme

Rei444 commented 1 year ago

i am sorry. image

stokie-ant commented 1 year ago

Could you run this, hit stop and paste the output for me getpdharray.zip It's just a loop that gets/should get data from the perf counter

Rei444 commented 1 year ago

sorry my virus/malware tools on system blocked this zip/exe. Can you write a powershell-script that can do this?

Rei444 commented 1 year ago

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.diagnostics/get-counter?view=powershell-7.3

rdoursenaud commented 1 year ago

What I got:

PdhOpenQueryA Handle: 24949456 Return: 0
PdhAddEnglishCounterA Handle: 0 Return: -1073738824
PdhGetFormattedCounterArrayA 1 Buffer size: 0 Item count: 0 Return: -1073738820
PdhGetFormattedCounterArrayA 2 Buffer size: 0 Item count: 0 Return: -1073738820
stokie-ant commented 1 year ago

Sorry about this guys. This stuff makes me hate Microsoft. -1073738824 means the counter cannot be found

Can you open the new smartie. Go to the perf tab and see if you have a counter that roughly translates to Object: Processor Information Counter: % Processor Utility

stokie-ant commented 1 year ago

I think I've sorted it. I ended up installing German windows in a virtual machine and found a method that is hopefully more reliable than the windows api for getting the localized counter names This is just the bare .exe LCDSmartie_x32.zip LCDSmartie_x64.zip

Rei444 commented 1 year ago

Works great. Thank you very very much. Unfortunately the Updatespeed is just too high, you can limit it to one value each second or a addirtional parameter control by myself e.g. $SysCPUSpeedGhz(x) $SysCPUUsage(x) x = 1/10 second Thanks a lot

stokie-ant commented 1 year ago

Is it more the spikes that bother you? Try this one. I've set it to interpolate with the last value. If it's still too jumpy I'll experiment with some other smoothing algorithm LCDSmartie_x32.zip LCDSmartie_x64.zip

limbo666 commented 1 year ago

Trying to use these functions with 5.5.4.15B and I'm getting zero as result on my systems. I suppose it is something about how performance monitors are getting exposed on the system

I have manage to compile a simple plugin called cput to check if I can get CPU usage and this works fine cput.zip. What I'm using here is the PerformanceCounter("Processor", "% Processor Time", "_Total") function available on .net framework.

I'm pretty sure that stokie-ant will fix this tiny issue in future releases.

stokie-ant commented 1 year ago

Do you get anything from the perf tab in settings and does it work? image_2023-07-10_145449548

There's a lot of fiddly bits due to trying to support wide characters and localized strings.

For those functions, currently I'm fetching the localized strings from the registry string value 'Counter' in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\CurrentLanguage' It's a long text string of the localized counter names with numbers that I hoped to be consistent across language variants. They're not consistent across windows versions though. Copy the string so you can search through using your favourite text editor example: 2454 maps to localized 'Processor Information' on windows 11 English and German that I tested but for windows 7 its 1848. Having a quick look now it seems that it's actually 3518 on the wife's windows 10

Are you using Windows 10? I can see that this might fail for that

[edit] Yes it does fail on windows 10

limbo666 commented 1 year ago

Well... it fails also on Win 11 And yes under perf tab I can get values Take a look at this: image

I will test it on Win 10 as well tomorrow to see if I get perf stats there as well and post an update

stokie-ant commented 1 year ago

2 things I can think of: 1, Check the version in the info tab. It should be >10 and >10.0.22000 for win 11 If that's wrong then the manifest is either missing or not being read properly. This is required to detect windows greater than 8 and use a different counter. Give thanks to Ms for these "features". 2, Check that registry entry I mentioned before. Make sure the value 2454 has 'Processor Information' underneath. Don't change anything in there though, perf counters are temperamental as it is. Let me know if you have a different number above 'Processor Information'. If so then it's back to the drawing board on this one

limbo666 commented 1 year ago

On Windows 11 the reported version is: 10.0.23493 image I'm running on insider preview image Manifest file on my LCD Smartie folder is the following: LCDSmartie.exe.Manifest.txt

The contents of the "intimidating" Counter Multi-String can be found on the file attached below counter.txt

`2454
Other queries - Successful`

and

2520
Processor Information 

Let me know if you need any more tests or reports. I will be happy to help. Do you think that reports from other system will be helpful on this case?

stokie-ant commented 1 year ago

Dammit, that's what I was afraid of. I'm going to take another look at the Pdhaddenglishcounter function. It should work, I must be doing something wrong or misunderstanding the documentation

stokie-ant commented 1 year ago

I got the PdhAddEnglishCounter function to work. I've tested it on English and German Win 11 and English Win 10. If you have a system in any other language than English to test on that would be helpful LCDSmartie_exe.zip

limbo666 commented 1 year ago

I just tested it to my PC running on English Win 11. I got lucky because I worked on settling up an old hardware with Greek Win 10 for a friend (normally I don't use Greek editions of Windows) and this allowed me to test the build on this PC as well. I got success in both cases! Win11_en en_win11_64bit Win10_gr gr_win10_64bit

From my point of view I call this a success and I think this issue should be closed. I have to report a new minor bug discovered during the tests regarding the desktop.dll though (https://github.com/stokie-ant/lcdsmartie-laz/issues/14)

rdoursenaud commented 1 year ago

I got the PdhAddEnglishCounter function to work. I've tested it on English and German Win 11 and English Win 10. If you have a system in any other language than English to test on that would be helpful LCDSmartie_exe.zip

This fixes the issue for me too!

Running:

Windows 11
Version 22H2 (22621.1992)
French version

Thanks ❤️

stokie-ant commented 1 year ago

I'll go ahead and close this then. Thank you for your patience and help in getting it fixed