Wrote a Processor performance counter, using the Performance Data Helper api (PDH).
It reads the performance used in percentages from all Logical Processors and the Total average.
There are 3 functions,
- InitProcessorPerformanceCounter
- GetProcessorPerformance
- CloseProcessorPerformanceCounter
Call "GetProcessorPerformance" once per second, the percentages are saved in the pProcessorPercentages buffer.
I've tested it only with Windows 8.1.
Would be nice if you guys can test if it works on an other OS.
Marinus
Hi Marinus,
Well it runs on Windows 2000. Are you interested in Win98?
Logical Processors: 1
% Processor Time
Processor : 0 Total
Percentage: 000% 000%
Regards,
Steve N.
Thanks Steve,
No need to test on win98 I think.
MSDN:
Minimum supported client for PDH is Windows XP
Minimum supported server Windows Server 2003
Does it run ok on Windows 2000?
Because I see your percentages are zero, do they give the same result as in TaskManager performance tab?
This is the result on my PC,
Logical Processors: 12
Percentage processortijd
Processor : 0 1 2 3 4 5 6 7 8 9 10 11 Total
Percentage: 000% 003% 005% 001% 001% 001% 011% 000% 000% 000% 008% 000% 003%
deleted
Thanks nidud,
Do the percentages change over time and show the realtime CPU load just like in TaskManager?
deleted
OK :t,
Then it works on WinXP too. :biggrin:
And on Win7-64 :t
Logical Processors: 4
% Tempo processore
Processor : 0 1 2 3 Total
Percentage: 006% 000% 003% 000% 002%
Works on Win10-64 (but gives a warning about unsigned code which I ignored).
Total % doesn't really change unless most of the core % are all up.
Thanks guys,
@sinsi, Total should give us the average % of all processors.
Is the Total value not correct on your Win10-64?
Seems correct, it's hard to get 8 cores over a few percent each :badgrin:
Thanks. :biggrin:
Hi,
Quote from: Siekmanski on May 03, 2016, 08:25:24 AM
Does it run ok on Windows 2000?
Because I see your percentages are zero, do they give the same result as in TaskManager performance tab?
Yes, seems to work the same. Here is one captured when the
browser froze up for a while.
Logical Processors: 1
% Processor Time
Processor : 0 Total
Percentage: 100% 100%
Regards,
Steve N.
Marinus,
I am not sure how to run the test piece but its padding along on very low percentages and the highest I have seen is 6%. OS is Win10 Professional.
Logical Processors: 12
% Processor Time
Processor : 0 1 2 3 4 5 6 7 8 9 10 11 Total
Percentage: 000% 001% 003% 001% 000% 000% 000% 000% 000% 000% 000% 000% 000%
Hi Steve,
It runs ok then on Win2000.
Hi hutch,
It shows the CPU load per logical processor.
In your case there are processes running on processor 1, 2 and 3 at low speed.
Total = the average CPU load of all processors = 1+3+1=5/12=0.42 rounded to zero.
On Win8-32 works fine
Logical Processors: 4
% загруженности процессора
Processor : 0 1 2 3 Total
Percentage: 000% 000% 001% 000% 000%
Thank you for testing. :t