Closed naveennamani closed 3 years ago
Hello,
After your question about "windows APIs available to monitor the CPU usage and per process CPU" I had a look and found 2 differents approaches.
The first one is based on somewhat standards API GetSystemTimes
& GetProcessTimes
. Both these functions are available in PythonForWindows (using windows.winproxy
) and you can also use WinProcess.time_info
for the later.
Here is two samples I found based on this method : http://www.philosophicalgeek.com/2009/01/03/determine-cpu-usage-of-current-process-c-and-c/ & https://stackoverflow.com/questions/23143693/retrieving-cpu-load-percent-total-in-windows-with-c.
The other approach may be Performance Counters
which are documented here : https://docs.microsoft.com/en-us/windows/win32/perfctrs/about-performance-counters
The Performance Counters
methods are not in PythonForWindows for now. And from what a read on the link :Windows Performance Counters are optimized for administrative/diagnostic data discovery and collection. They are not appropriate for high-frequency data collection or for application profiling since they are not designed to be collected more than once per second.
it will heavly depends on your use-case.
Does one of those approach fit your use-case ?
Ok, I'll check the tutorials, stackoverflow and come back to you if I get any implementable solution using the APIs mentioned by you, however while I was trying I found that windows.winproxy doesn't has GetSystemTimes
API, it has GetSystemTime
API only.
Okay, thank you for the feedback about the missing GetSystemTimes
Indeed, I just added windows.winproxy.GetSystemTimes
in e7789312.
I am closing the issue, do not hesitate to reopen it if you feel something else is missing for your use case after testing/exploring.
Also feel free to open other issues if you have any feedback/ideas.
Thank you,
I'm wondering if there are any windows APIs available to monitor the CPU usage and per process CPU, memory, disk usage as shown by the Windows Task Manager. The solution may not be quite straight forward, but this will be a good addition to the library and I really liked the simple interface provided by this library to work with windows from python.
Thanks for the library, and expecting more awesome feature additions.