2017-05-21 6 views
0

私は自分のCPU上に一連のプロセスをプロファイルしようとしています。非常に正確であるためには、perf statコマンドを使用して、プロセスで使用されたCPUサイクルの数を確認します。 これはトップとは異なります。ここでは、スナップショットで使用されているCPUのパーセンテージのみが表示されます。Linuxのperfツール - 複数のプロセスを同時にプロファイリングする方法は? CPUサイクルのパーセンテージを抽出するには?

残念ながら、複数のプロセスを同時にプロファイルする方法は見つかりませんでした。これは可能ですか?

2番目の質問として、使用されたCPUサイクルだけでなく、同じ時間間隔で使用されたCPUサイクル(またはパーセンテージ)の総量も表示できますか?あなたはすべてのためのperf stat -p PID1,PID2,PID3を実行してみることができます

答えて

1

http://man7.org/linux/man-pages/man1/perf-stat.1.html

-p, --pid=<pid> 
    stat events on existing process id (comma separated list) 

スレッドを分離するために、定期的な印刷や--per-threadを有効にするには便利な-I msecsオプションもあります(... pidof、のpgrep、などとそれらを取得)したいのpid 。

また-Aまたは一部--per- *オプションでシステム全体のperf stat -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). 
関連する問題