PerformanceCounter 性能计数器的使用
来源:互联网 发布:java获取list泛型类型 编辑:程序博客网 时间:2024/05/19 12:15
1:获取性能计数器类别列表
public static void GetCategoryNameList(){ PerformanceCounterCategory[] myCat2; myCat2 = PerformanceCounterCategory.GetCategories(); for (int i = 0; i < myCat2.Length; i++) { Console.WriteLine(myCat2[i].CategoryName.ToString()); }}
2:获取性能计数器类别下的实例的名称实例下的性能计数器的名称
public static void GetInstanceNameListANDCounterNameList(string CategoryName){ string[] instanceNames; ArrayList counters = new ArrayList(); PerformanceCounterCategory mycat = new PerformanceCounterCategory(CategoryName); try { instanceNames = mycat.GetInstanceNames(); if (instanceNames.Length == 0) { counters.AddRange(mycat.GetCounters()); } else { for (int i = 0; i < instanceNames.Length; i++) { counters.AddRange(mycat.GetCounters(instanceNames[i])); } } for (int i = 0; i < instanceNames.Length; i++) { Console.WriteLine(instanceNames[i]); } Console.WriteLine("******************************"); foreach (PerformanceCounter counter in counters) { Console.WriteLine(counter.CounterName); } } catch (Exception) { Console.WriteLine("Unable to list the counters for this category"); }}
private static void PerformanceCounterFun(string CategoryName, string InstanceName, string CounterName){ PerformanceCounter pc = new PerformanceCounter(CategoryName, CounterName, InstanceName); while (true) { Thread.Sleep(1000); float cpuLoad = pc.NextValue(); Console.WriteLine("CPU load = " + cpuLoad + " %."); }}
PerformanceCounterFun("Processor", "_Total", "% Processor Time");
0 0
- PerformanceCounter 性能计数器的使用
- C#中遍历所有的性能计数器PerformanceCounter
- 利用Windows性能计数器(PerformanceCounter)监控
- 利用Windows性能计数器(PerformanceCounter)监控
- 利用Windows性能计数器(PerformanceCounter)监控
- 关于windows2003的性能计数器使用心得
- 得到系统的进程使用情况,性能计数器的使用
- 使用powershell查看性能计数器
- 使用性能计数器监控应用程序
- vc下使用windows的性能计数器简介
- [转]vc下使用windows的性能计数器简介
- vc下使用windows的性能计数器简介
- 使用CPU计数器监视SQL Server性能的一点提示
- VC下使用 Windows 的性能计数器简介
- PerformanceCounter
- PerformanceCounter
- 使用性能计数器收集性能数据
- 一些性能计数器的说明
- 搜索引擎原理 – 正排索引、倒排索引以及齐普夫法则
- ios学习资料
- php常用的的全局变量
- Bootstrap 提示框
- DRM security
- PerformanceCounter 性能计数器的使用
- 关于设计模式的思考——创建型模式
- c#Com控件开发
- FZU 1054阅读顺序
- Android应用图标替换
- hdu 1016 Prime Ring Problem
- redis列表键的底层实现之链表
- 欢迎使用CSDN-markdown编辑器
- php7/mysql/apache/windows环境搭建