Linux性能工具-如何同时评测多个进程?如何提取CPU周期的百分比?

Linux性能工具-如何同时评测多个进程?如何提取CPU周期的百分比?,linux,command-line,profiling,perf,Linux,Command Line,Profiling,Perf,我试图在我的CPU上分析一组进程。为了非常精确,我想使用perf stat命令查看我的进程使用了多少CPU周期。 这与top不同,在top中,我只看到快照中使用的CPU百分比 不幸的是,我没有找到一种同时分析多个进程的方法。这可能吗 还有第二个问题:是否不仅可以查看使用的CPU周期,还可以查看在同一时间间隔内使用的CPU周期总量(或百分比)?您可以尝试为每个pid运行perf stat-p PID1、PID2、PID3(使用pidof、pgrep等获取它们) 我也在寻找类似的东西,因为我的例子中

我试图在我的CPU上分析一组进程。为了非常精确,我想使用
perf stat
命令查看我的进程使用了多少CPU周期。 这与top不同,在top中,我只看到快照中使用的CPU百分比

不幸的是,我没有找到一种同时分析多个进程的方法。这可能吗


还有第二个问题:是否不仅可以查看使用的CPU周期,还可以查看在同一时间间隔内使用的CPU周期总量(或百分比)?

您可以尝试为每个pid运行
perf stat-p PID1、PID2、PID3
(使用pidof、pgrep等获取它们)


我也在寻找类似的东西,因为我的例子中的线程被固定在内核上,所以我可以使用
--per-core
-A
来获得每个内核的分解。我假设
--per-thread
需要
tid
,这在运行可执行文件之前是未知的
 -p, --pid=<pid>
    stat events on existing process id (comma separated list)
   -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).