跟踪每个进程的 CPU 和内存使用情况
我怀疑我的一个应用程序占用的 CPU 周期比我想要的要多。 问题是 - 它突然发生,仅仅查看任务管理器对我没有帮助,因为它只显示立即使用情况。
有没有一种方法(在 Windows 上)可以跟踪 CPU 和 CPU 的历史记录? 某些进程的内存使用情况。 例如,我将开始跟踪“firefox”,大约一个小时后将看到其 CPU 和内存的图表。 该小时内的内存使用情况。
我正在寻找一个现成的工具或一种编程方式来实现这一目标。
I suspect that one of my applications eats more CPU cycles than I want it to. The problem is - it happens in bursts, and just looking at the task manager doesn't help me as it shows immediate usage only.
Is there a way (on Windows) to track the history of CPU & Memory usage for some process. E.g. I will start tracking "firefox", and after an hour or so will see a graph of its CPU & memory usage during that hour.
I'm looking for either a ready-made tool or a programmatic way to achieve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
按 Win+R,输入
perfmon
并按 Enter。 打开“性能”窗口后,单击 + 符号将新计数器添加到图表中。 计数器是 PC 工作方式的不同方面,并根据相似性分为称为“性能对象”的组。对于您的问题,您可以选择“进程”、“内存”和“处理器”性能对象。 然后,您可以实时查看这些计数器。
您还可以指定实用程序来保存性能数据以供稍后检查。 为此,请选择左侧面板中的“性能日志和警报”。 (它就在系统监视器控制台下方,它为我们提供了上述计数器。如果不存在,请单击“文件”>“添加/删除管理单元”,单击“添加”并在“性能日志和警报”中选择“性能日志和警报”。列表”。)从“性能日志和警报”中,在“计数器日志”下创建新的监控配置。然后您可以添加计数器、指定采样率、日志格式(二进制或纯文本)和日志位置。
Press Win+R, type
perfmon
and press Enter. When the Performance window is open, click on the + sign to add new counters to the graph. The counters are different aspects of how your PC works and are grouped by similarity into groups called "Performance Object".For your questions, you can choose the "Process", "Memory" and "Processor" performance objects. You then can see these counters in real time
You can also specify the utility to save the performance data for your inspection later. To do this, select "Performance Logs and Alerts" in the left-hand panel. (It's right under the System Monitor console which provides us with the above mentioned counters. If it is not there, click "File" > "Add/remove snap-in", click Add and select "Performance Logs and Alerts" in the list".) From the "Performance Logs and Alerts", create a new monitoring configuration under "Counter Logs". Then you can add the counters, specify the sampling rate, the log format (binary or plain text) and log location.
Process Explorer 可以显示进程占用的总 CPU 时间,以及每个进程的历史图。
Process Explorer can show total CPU time taken by a process, as well as a history graph per process.
使用 perfmon.exe,我尝试使用“进程”计数器下的“私有字节”计数器来跟踪内存使用情况,效果很好。
Using perfmon.exe, I have tried using the "Private Bytes" counter under "Process" counters for tracking memory usage and it works well.
我使用 taskinfo 作为 CPU/RAM/IO 速度的历史图。
http://www.iarsn.com/taskinfo.html
但是阵阵无响应,听起来更严重例如由于 HD/SS 驱动器故障而导致的中断时间。
I use taskinfo for history graph of CPU/RAM/IO speed.
http://www.iarsn.com/taskinfo.html
But bursts of unresponsiveness, sounds more like interrupt time due to a falty HD/SS drive.
在 Windows 10 下,任务管理器可以显示累积的 CPU 小时数。 只需前往“应用程序历史记录”选项卡和“删除使用历史记录”即可。 现在让程序运行一两个小时:
这不会按选项卡细分浏览器中的使用情况。 通常,不活动的选项卡会执行大量工作,每个打开的选项卡都会消耗能量并降低您的电脑速度。
Under Windows 10, the Task Manager can show you cumulative CPU hours. Just head to the "App history" tab and "Delete usage history". Now leave things running for an hour or two:
What this does NOT do is break down usage in browsers by tab. Quite often inactive tabs will do a tremendous amount of work, with each open tab using energy and slowing your PC.
下载进程监视器
启动进程监视器
根据需要设置过滤器
进入菜单选项 > 分析事件
单击“生成线程分析事件”,选择频率,然后单击“确定”。
要随时查看采集的历史数据,进入菜单“工具>” 流程活动摘要
Download process monitor
Start Process Monitor
Set a filter if required
Enter menu Options > Profiling Events
Click "Generate thread profiling events", choose the frequency, and click OK.
To see the collected historical data at any time, enter menu Tools > Process Activity Summary
也许你可以用这个。 它应该适合您,并将报告指定进程的处理器时间。
maybe you can use this. It should work for you and will report processor time for the specified process.
我同意,perfmon.exe 允许您为要监视的任何进程添加计数器(右键单击右侧面板)。
绩效对象:流程
选中“从列表中选择实例”并选择 Firefox。
I agree, perfmon.exe allows you to add counters (right click on the right panel) for any process you want to monitor.
Performance Object: Process
Check "Select instances from list" and select firefox.
WMI 是 Windows Management Instrumentation,它内置于所有最新版本的 Windows 中。 它允许您以编程方式跟踪 CPU 使用情况、磁盘 I/O 和内存使用情况等。
Perfmon.exe 是该界面的 GUI 前端,可以监视进程、将信息写入日志,并允许您在事后分析日志。 它不是世界上最优雅的程序,但它确实可以完成工作。
WMI is Windows Management Instrumentation, and it's built into all recent versions of Windows. It allows you to programmatically track things like CPU usage, disk I/O, and memory usage.
Perfmon.exe is a GUI front-end to this interface, and can monitor a process, write information to a log, and allow you to analyze the log after the fact. It's not the world's most elegant program, but it does get the job done.
Process Lasso 的设计更多是为了流程自动化和优先级优化,而不是图形。 也就是说,它确实提供每个进程的CPU利用率历史记录(在图表上绘制为白线),但它不提供每个进程的内存利用率历史记录。
免责声明:我是 Process Lasso 的作者,但实际上并不在这里认可它 - 因为有更好的解决方案(perfmon 是最好的)。
有史以来最好的东西是 Windows Vista+ 资源和性能监视器。 它可以跟踪一段时间内进程对 CPU、内存、网络和磁盘访问的使用情况。 它是一个很棒的整体系统信息实用程序,早就应该创建了。 除非我弄错了,否则它可以跟踪一段时间内每个进程的 CPU 和内存利用率(以及列出的其他内容)。
Process Lasso is designed more for process automation and priority class optimization, not graphs. That said, it does offer per-process CPU utilization history (drawn as a white line on the graph) but it does NOT offer per-process memory utilization history.
DISCLAIMER: I am the author of Process Lasso, but am not actually endorsing it here - as there are better solutions (perfmon being the best).
The best thing ever is Windows Vista+ Resource and Performance Monitor. It can track usage of CPU, Memory, Network, and Disk accesses by processes over time. It is a great overall system information utility that should have been created long ago. Unless I am mistaken, it can track per-process CPU and memory utilization over time (amongst the other things listed).
您还可以尝试使用 C#/Perl/Java 脚本使用 WMI 命令获取利用率数据,以下是其步骤。
我们需要执行 2 个 WMI 选择查询并应用 CPU% 利用率公式
1。 检索逻辑进程总数
2。 要检索 PercentProcessorTime、TimeStamp_Sys100NS(已应用 CPU 利用率公式获取实际利用率百分比)和 WorkSetPrivate (RAM) 的值,至少 2 次,睡眠间隔为 1 秒
3。 应用CPU%利用率公式
p2表示第二次检索的PercentProcessorTime,p1表示第一次检索的PercentProcessorTime,t2和t1针对TimeStamp_Sys100NS。
可以在链接 http://www.craftedforeveryone.com/cpu-and-ram-utilization-of-an-application-using-perl-via-wmi/
此逻辑适用于所有编程语言支持WMI查询
You can also try using a C#/Perl/Java script get the utilization data using WMI Commands, and below is the steps for it.
We need to execute 2 WMI Select Queries and apply CPU% utilization formula
1. To retrieve the total number of logical process
2. To retrieve the values of PercentProcessorTime, TimeStamp_Sys100NS ( CPU utilization formula has be applied get the actual utilization percentage)and WorkingSetPrivate ( RAM ) minimum of 2 times with a sleep interval of 1 second
3. Apply CPU% utilization formula
p2 indicated PercentProcessorTime retrieved for the second time, and p1 indicateds the PercentProcessorTime retrieved for the first time, t2 and t1 is for TimeStamp_Sys100NS.
A sample Perl code for this can be found in the link http://www.craftedforeveryone.com/cpu-and-ram-utilization-of-an-application-using-perl-via-wmi/
This logic applies for all programming language which supports WMI queries
虽然我还没有尝试过这个, ProcDump 似乎是一个更好的解决方案。
网站描述:
Although I have not tried this out, ProcDump seems like a better solution.
Description from site:
需要获取某些特定 Windows 服务器的状态和 CPU/内存使用情况。 我使用了以下脚本:
这是 Windows 搜索服务的示例。
There was a requirement to get status and cpu / memory usage of some specific windows servers. I used below script:
This is an example of Windows Search Service.
嗯,我看到 Process Explorer 可以做到这一点,尽管它的图表都不太方便。 仍在寻找替代/更好的方法来做到这一点。
Hmm, I see that Process Explorer can do it, although its graphs are not too convenient. Still looking for alternative / better ways to do it.
Perfmon.exe 内置于 Windows 中。
Perfmon.exe is built into windows.
您可能想看看Process Lasso。
You might want to have a look at Process Lasso.