Memory usage and time for execution for another process using C#?

半城伤御伤魂 提交于 2019-12-13 16:53:05

问题


I need the memory usage and processing time for an application loaded through another application. I am using C#. Currently I am using Process.WorkingSet to get memory usage similarly Process.TotalProcessTime to get time for execution, but it doesn't give any value. So have you make any suggestions?


回答1:


Use WMI to get this kind of info, well supported by the System.Management namespace. Get started by downloading the WMI Code Creator utility, it lets you experiment with queries and can auto-generate the C# you'll need.

You want to query Win32_Process, it provides lots of info about a process. PrivatePageCount would be a good measure for the amount of memory it uses that isn't shared by any other process. KernelModeTime and UserModeTime gives you time spent executing code.



来源:https://stackoverflow.com/questions/3959045/memory-usage-and-time-for-execution-for-another-process-using-c

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