I need to find the CPU usage of all the current running processes in the system (windows). I have got the list of processes and their handles using PSAPI. I could not find any usefull function of module to find their CPU usage. I am using C++ and visual studio. Guide Please.
Asked
Active
Viewed 4,559 times
4
-
Did you look at https://stackoverflow.com/a/23148493/5909613 ? – Jerome Reinländer Apr 12 '18 at 12:10
-
Yes bro i checked that out but that's not helping me. – Ubaid R Butt Apr 12 '18 at 12:29
-
I need some function that i give the id or the handle of the process and it returns me the CPU usage in Hz or GHz Something like that. – Ubaid R Butt Apr 12 '18 at 12:30
-
Hz is a frequency. You can't really express CPU usage as a frequency... – Jerome Reinländer Apr 12 '18 at 12:33
-
Any function that can give me the CPU usage in percentage but for each running process separately as well as overall CPU Utilization in percentage. Just like it is available in Task Manager. – Ubaid R Butt Apr 12 '18 at 12:37
-
@JeromeReinländer: Of course you can. It makes perfect sense to say that a process consuming 25% CPU time on an 1.6 Ghz CPU is taking up 400 Mhz. You can see that this is meaningful, because it allows us to predict that the same process will take 50% on a 800 Mhz CPU. – MSalters Apr 12 '18 at 12:51
-
@MSalters This is a very simplified view on a single core CPU, yes. – Jerome Reinländer Apr 12 '18 at 12:54
1 Answers
0
The best way is to set up Performance Counters (more information here) to track your application. You can do that programmatically via COM API.
Another approach is to use external tools. One of the best is SysInternals Process Monitor. I highly recommend this option.
sophros
- 11,665
- 7
- 38
- 61