性能计数器?

发布于 2024-08-23 16:44:15 字数 55 浏览 6 评论 0原文

我想监控内存 (RAM) 和物理磁盘的性能,我必须监控的 Perfmon 中的所有计数器有哪些?

I would like to monitor the performance of the Memory (RAM) and Physical Disk, what are all the counters in Perfmon that I have to monitor?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

内心旳酸楚 2024-08-30 16:44:15

Windows 计算机的性能信息存储在注册表的特定部分中。您可以使用注册表 API 来枚举计数器并获取它们的名称和值。

这里有一个教程:http://www.tenouk.com/ModuleP1.html

The performance information for a Windows machine is stored in a particular part of the registry. You use the registry API's to enumerate the counters and get their names and values.

Theres a tutorial here: http://www.tenouk.com/ModuleP1.html

坠似风落 2024-08-30 16:44:15

您没有说明您使用的是托管代码还是非托管代码。如果是后者,您可以使用 PerformanceCounter 对象并像这样初始化它。

Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "Process";
pc.CounterName = "Working Set - Private";
pc.InstanceName = currentProcess.ProcessName;
var myProcessMemoryUsage = (long)pc.NextValue();

作为示例,上面的代码检索当前进程的私有工作集性能计数器信息。

PerformanceCounter pcRam = new PerformanceCounter();
pcRam.CategoryName = "Memory";
pcRam.CounterName = "Available MBytes";
int mem = (int)pcRam.NextValue();

该计数器将向您显示计算机上可用的 RAM 量(以兆字节为单位)。

您可以查看性能监视器本身中的所有性能计数器。您应该能够看到类别和计数器名称。

You didn't state whether you are using managed or unmanaged code. If the latter, you can use the PerformanceCounter object and initialise it like so.

Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "Process";
pc.CounterName = "Working Set - Private";
pc.InstanceName = currentProcess.ProcessName;
var myProcessMemoryUsage = (long)pc.NextValue();

As an example, the above code retrieves the private working set performance counter information for the the current process.

PerformanceCounter pcRam = new PerformanceCounter();
pcRam.CategoryName = "Memory";
pcRam.CounterName = "Available MBytes";
int mem = (int)pcRam.NextValue();

This counter will show you the amount of RAM available on the machine in megabytes.

You can have a look at all the performance counters in Performance Monitor itself. You should be able to see both the categories and the counter name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文