我正在尝试在我的CPU上配置一组进程。为了非常精确,我想使用perf stat
命令查看我的进程使用了多少CPU周期。
这与top不同,我只看到快照中使用的CPU的百分比。
不幸的是,我没有找到同时分析多个进程的方法。这可能吗?
作为第二个问题:是否有可能不仅看到使用的CPU周期,还能看到在同一时间间隔内使用的CPU周期总量(或百分比)?
答案 0 :(得分:2)
你可以尝试为你想要的每个pid运行perf stat -p PID1,PID2,PID3
(用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)
还有一个有用的-I msecs
选项可以启用定期打印,--per-thread
可以分隔线程。
还可以使用perf stat -a
或某些--per- *选项尝试系统级-A
: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).