您的位置:首页 > 运维架构

客户端性能测试通过performanceCounter监控客户端性能指标

2009-09-27 14:22 543 查看
PerformanceCounter PTCounter = new PerformanceCounter("Process",
"% Processor Time",
"AliIM");
logfile("% Processor Time:" + PTCounter.NextValue().ToString());
//内存
PerformanceCounter WSCounter = new PerformanceCounter("Process",
"Working Set",
"AliIM");
logfile("Working Set:" + ((double)WSCounter.NextValue() / 1024).ToString());

//内存最高值
PerformanceCounter MemeryCounter = new PerformanceCounter("Process",
"Working Set Peak",
"AliIM");
logfile("Working Set Peak:" + ((double)MemeryCounter.NextValue() / 1024).ToString());

//虚拟内存
PerformanceCounter PBCounter = new PerformanceCounter("Process",
"Private Bytes",
"AliIM");
logfile("Private Bytes:" + ((double)PBCounter.NextValue() / 1024).ToString());

//句柄数
PerformanceCounter HCCounter = new PerformanceCounter("Process",
"Handle Count",
"AliIM");
logfile("Handle Count:" + HCCounter.NextValue() .ToString());

//线程数Thread Count
PerformanceCounter TCCounter = new PerformanceCounter("Process",
"Thread Count",
"AliIM");
logfile("Thread Count:" + TCCounter.NextValue() .ToString());



//补充得到GDI OBJECTS

Process process;
process = System.Diagnostics.Process.GetProcessesByName("AliIM")[0];

logfile("GDI Objects Count:" + GetGuiResources(process.Handle, 0));



[DllImport("User32")]

extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: