我在程序里面做性能列表,可以实时得到它所占用的性能!
这个程序的cpu使用率如何能得到?如果能给我一个这样的程序就最好了!
这个程序的cpu使用率如何能得到?如果能给我一个这样的程序就最好了!
解决方案 »
- ASP.NET C#网上报名时间截止问题
- 在aspx.cs中怎么判断文本文件读取到了最后一行
- 怎么样在ListBox中放入一个树控件??????????????????
- [Session]在ASP.NET中,能不能做到 网页 "后退"时候使得Session实效?
- SQL SERVER的一个字段设 Nvarchar 太小,设 Ntext 又不支持全文搜索,要怎么办?
- 请用过三楼楼长老兄oa系统的大侠帮一下忙,谢谢!
- UltraWebGrid如何使用非绑定模式添加数据
- 页面显示的问题?
- checkboxlist 中每项分别与数据表中每字段数据绑定问题!!
- 请教:在ASP.net中如何实现文件重命名呢?
- vb.net问题 求助!
- 关于大文件上传的问题
PagedMemorySize 获取分页的内存大小。
PagedSystemMemorySize 获取分页的系统内存大小。
PeakPagedMemorySize 获取峰值分页内存大小。
PeakVirtualMemorySize 获取峰值虚拟内存大小。
VirtualMemorySize 获取进程的虚拟内存大小。
WorkingSet 获取关联进程的物理内存使用情况。
.....
Process 组件是很有用的工具。使用 Process 组件,可以获取当前运行的进程的列表,或者启动新的进程。Process 组件用于访问系统进程。初始化 Process 组件后,可使用该组件来获取有关当前运行的进程的信息。此类信息包括线程集、加载的模块(.dll 和 .exe 文件)和性能信息(如进程当前使用的内存量)。
using System;
using System.Diagnostics;
using System.Threading;
public class CpuLoadInfo
{ // auxiliary print methods
private static void Say ( string txt )
{
Console.WriteLine(txt);
} // auxiliary print methods
private static void Say()
{
Say("");
} // The main method. Command line arguments are ignored.
[STAThread]
public static void Main()
{
Say("$Id: CpuLoadInfo.cs,v 1.2 2002/08/17 17:45:48 rz65 Exp $");
Say(); Say("Attempt to create a PerformanceCounter instance:");
Say("Category name = " + CategoryName);
Say("Counter name = " + CounterName);
Say("Instance name = " + InstanceName);
PerformanceCounter pc
= new PerformanceCounter(CategoryName,CounterName,InstanceName);
Say("Performance counter was created.");
Say("Property CounterType: " + pc.CounterType);
Say(); Say("Property CounterHelp: " + pc.CounterHelp);
Say();
Say("Entering measurement loop."); while (true)
{
Thread.Sleep(1000); // wait for 1 second
float cpuLoad = pc.NextValue();
Say("CPU load = " + cpuLoad + " %.");
}
} // constants used to select the performance counter.
private const string CategoryName = "Processor";
private const string CounterName = "% Processor Time";
private const string InstanceName = "_Total";
}