如何从C#配置内存和CPU使用情况

Dan*_*lba 4 .net c# instrumentation profiling process

我正在运行一个使用C#启动两个进程的测试.我需要获得我的进程使用的顶级内存和CPU.请有人可以给我一个关于如何使用托管代码进行操作的指南?(我也使用mono在linux上运行它).

该架构如下:

该过程test.exe启动两个过程:A.exeB.exe.我需要为进程A和B测量meausre max memory和CPUtest.exe

有可能吗?提前致谢

Esp*_*rud 8

您可以使用System.Diagnostics.Process该类来启动该过程.然后,您可以检查UserProcessorTime,TotalProcessorTime,PeakWorkingSet64和其他属性,以检查处理器使用率和内存使用情况.检查此System.Diagnostics.Process的MSDN文章.