Measure a process CPU and RAM usage

可紊 提交于 2019-12-13 03:42:11

问题


I've found various ways to track down CPU's and RAM's usage from within a process, in C#. I'd like to obtain those infos for an external program (like providing its PID).

Is there anything in the .NET framework that can help me?

Thanks


回答1:


you can use process class




回答2:


Use Performance Monitor, and add counters for specific processes.

If you need to analyse the results, you can have them written to a performance log.




回答3:


You could host a PowerShell RunSpace and call stuff in there - it's got a lot more native stuff dealing with this type of thing.




回答4:


You can pass an instance into a System.Diagnostics.PerformanceCounter constructor - this should allow you to specify the process instance you want to monitor



来源:https://stackoverflow.com/questions/1754638/measure-a-process-cpu-and-ram-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!