2017-05-21 1 views
0

Ich versuche, eine Reihe von Prozessen auf meiner CPU zu profilieren. Um sehr präzise zu sein, möchte ich den Befehl perf stat verwenden, um zu sehen, wie viele CPU-Zyklen meine Prozesse verwendet haben. Das ist anders als oben, wo ich nur den Prozentsatz der CPU sehe, die in einem Snapshot verwendet wird.Linux Perf Tools - Wie erstellt man mehrere Prozesse gleichzeitig? Wie extrahiere ich den Prozentsatz der CPU-Zyklen?

Leider habe ich keine Möglichkeit gefunden, mehrere Prozesse gleichzeitig zu profilieren. Ist das möglich?

Und als zweite Frage: Ist es möglich, nicht nur die verwendeten CPU-Zyklen zu sehen, sondern auch die Gesamtanzahl der CPU-Zyklen (oder den Prozentsatz), die im gleichen Zeitintervall verwendet werden?

Antwort

1

Sie können versuchen, perf stat -p PID1,PID2,PID3 für jeden laufenden pid Sie wollen (erhalten sie mit pidof, pgrep, etc ...) http://man7.org/linux/man-pages/man1/perf-stat.1.html

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

Es gibt auch nützliche -I msecs Option periodische Druck- und --per-thread zu ermöglichen Fäden zu trennen .

Versuchen Sie auch systemweite perf stat -a mit -A oder einigen --per- * Optionen: 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). 
Verwandte Themen