Ere*_*osM 3 linux command-line profiling perf
我正在尝试在我的 CPU 上分析一组进程。为了非常精确,我想使用perf stat命令来查看我的进程使用了多少 CPU 周期。这与 top 不同,在那里我只看到快照中使用的 CPU 百分比。
不幸的是,我没有找到同时分析多个进程的方法。这可能吗?
作为第二个问题:是否可以不仅看到使用的 CPU 周期,还可以看到在同一时间间隔内使用的 CPU 周期总量(或百分比)?
您可以尝试perf stat -p PID1,PID2,PID3为您想要的每个 pid运行(使用 pidof、pgrep 等获取它们...)http://man7.org/linux/man-pages/man1/perf-stat.1.html
-p, --pid=<pid>
stat events on existing process id (comma separated list)
Run Code Online (Sandbox Code Playgroud)
还有一个有用的-I msecs选项来启用定期打印和--per-thread分离线程。
还可以尝试在系统范围内perf stat -a使用-A或一些 --per-* 选项:http ://man7.org/linux/man-pages/man1/perf-stat.1.html
-a, --all-cpus
system-wide collection from all CPUs (default if no target is
specified)
-A, --no-aggr
Do not aggregate counts across all monitored CPUs.
--per-socket
Aggregate counts per processor socket for system-wide mode
measurements. This is a useful mode to detect imbalance between
sockets. To enable this mode, use --per-socket in addition to -a.
(system-wide). The output includes the socket number and the
number of online processors on that socket. This is useful to
gauge the amount of aggregation.
--per-core
Aggregate counts per physical processor for system-wide mode
measurements. This is a useful mode to detect imbalance between
physical cores. To enable this mode, use --per-core in addition
to -a. (system-wide). The output includes the core number and the
number of online logical processors on that physical processor.
--per-thread
Aggregate counts per monitored threads, when monitoring threads
(-t option) or processes (-p option).
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2084 次 |
| 最近记录: |