News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Processor performance counter

Started by Siekmanski, May 03, 2016, 07:54:55 AM

Previous topic - Next topic

Siekmanski

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
Creative coders use backward thinking techniques as a strategy.

FORTRANS

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.

Siekmanski

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%
Creative coders use backward thinking techniques as a strategy.

nidud

#3
deleted

Siekmanski

Thanks nidud,

Do the percentages change over time and show the realtime CPU load just like in TaskManager?
Creative coders use backward thinking techniques as a strategy.

nidud

#5
deleted

Siekmanski

OK  :t,
Then it works on WinXP too.  :biggrin:
Creative coders use backward thinking techniques as a strategy.

jj2007

And on Win7-64 :t

Logical Processors: 4

% Tempo processore

Processor :  0    1    2    3   Total
Percentage: 006% 000% 003% 000% 002%

sinsi

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.
🍺🍺🍺

Siekmanski

Thanks guys,

@sinsi, Total should give us the average % of all processors.
Is the Total value not correct on your Win10-64?
Creative coders use backward thinking techniques as a strategy.

sinsi

Seems correct, it's hard to get 8 cores over a few percent each :badgrin:
🍺🍺🍺

Siekmanski

Creative coders use backward thinking techniques as a strategy.

FORTRANS

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.

hutch--

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%

Siekmanski

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.

Creative coders use backward thinking techniques as a strategy.