内存使用和执行时间,使用C#另一个进程?执行时间、进程、内存

2023-09-06 07:53:20 作者:秋季的野百合

我所需要的内存使用量和处理时间,通过其他应用程序加载的应用程序。我使用C#。目前我使用 Process.WorkingSet 来获得内存使用情况 同样 Process.TotalProcessTime 得到执行时间,但它不给任何价值。因此,有你做什么建议?

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?

推荐答案

使用WMI得到这样的信息,很好的支持System.Management命名空间。获得通过下载启动的 WMI code Creator实用程序,它可以让你尝试查询,并可以自动生成C#你需要。

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.

您要查询Win32_Process的,它提供了大量的有关进程的信息。 PrivatePageCount将是一个很好的措施为的内存量,它使用了没有通过任何其他进程共享。 KernelModeTime和UserModeTime给你的时间花费在执行code。

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.