-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[windows] - Introduce PdhGetRawCounterArrayW #254
[windows] - Introduce PdhGetRawCounterArrayW #254
Conversation
ret := make([]PdhRawCounterItem, 0, len(items)) | ||
for _, item := range items { | ||
instance := windows.UTF16PtrToString(item.SzName) | ||
if filterTotal && strings.Contains(instance, "_Total") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to worry if this is a non-English Windows system? Just wondering if we might have something besides "_Total".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For instance name? Nope. The name remains _Total
.
I did a quick test on windows VM by changing language to Spanish.
For counter name? yes, the language makes a lot of change.
Hence, I've updated the AddCounter
function in this PR. PTAL!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to worry if this is a non-English Windows system? Just wondering if we might have something besides "_Total".
For this specific piece of code? Nope.
h, err = PdhAddEnglishCounter(q.Handle, counterPath, 0) | ||
} else { | ||
h, err = PdhAddCounter(q.Handle, counterPath, 0) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leehinman These are two different API calls.
PdhAddCounter is language specific.
PdhAddEnglishCounter is language neutral.
💚 Build Succeeded
History
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking on the language pieces.
@mauri870 can you take a look when you have a moment? You left some comments :) |
Thanks, I have looked at it again and codewise it looks good to me. I'm not too familiar with windows but the usage here seems correct. |
While performing benchmarking, I noticed that by using https://learn.microsoft.com/en-us/windows/win32/api/pdh/nf-pdh-pdhgetrawcounterarrayw we can achieve faster results with reduced memory usage.
This PR adds the methods for PdhGetRawCounterArrayW function.
It also does following thing to improve memory benchmarks:
n+1
instance names corresponding ton
CPU cores.Processor Information(0)/ % Idle Time
refers to the idle time spent by CPU core0
Processor Information(1)/ % Idle Time
refers to the idle time spent by CPU core1
Processor Information(n)/ % Idle Time
refers to the idle time spent by CPU coren
Processor Information(_Total)/ % Idle Time
refers to the average idle time spent for all CPUs.