perf
17 commands
17 shown
Record CPU cycles
Record performance data with call-graph info
perf record -g ./my_app
Show perf report
Interactive display of recorded perf data
perf report
List available events
List all supported perf events on current system
perf list
Stat command
Show hardware counters for a command
perf stat ls -la
Record with specific event
Record only cache-miss events
perf record -e cache-misses ./my_app
Top-like live view
Show live per-function CPU usage (like top)
perf top
Annotate hot functions
Show annotated assembly for hottest function
perf annotate
Flamegraph data collection
Collect data suitable for flamegraph generation
perf record -F 99 -ag -- sleep 30 && perf script > out.perf
Count syscalls
Count specific syscall events
perf stat -e syscalls:sys_enter_read ./my_app
Attach to running process
Profile an already-running process for 5 seconds
perf record -p 1234 sleep 5
Live CPU flame call graph
Live top hot functions with caller chains; dwarf unwind works without frame pointers
perf top -g --call-graph dwarf
System-wide sampled record
Sample whole machine at 99Hz for 30s, then print collapsed report; 99Hz dodges lockstep aliasing
perf record -F 99 -a -g -- sleep 30 && perf report --stdio
Flame graph pipeline
Turn perf.data into an interactive flame graph SVG (Brendan Gregg FlameGraph tools)
perf script | stackcollapse-perf.pl | flamegraph.pl > flame.svg
Detailed counter stats
Run with three -d for L1/LLC/TLB and stalled-cycle detail; reveals memory-bound vs CPU-bound
perf stat -d -d -d -- ./app
Scheduler latency analysis
Record context switches then show per-task wakeup latency; find runqueue starvation
perf sched record -- sleep 10 && perf sched latency --sort max
Syscall trace via perf
strace-like syscall trace with -s summary; lower overhead, no ptrace stop-the-world
perf trace -s -p <pid>
Dynamic probe on function
Add a kprobe with an argument, then record it; inspect kernel internals without rebuilding
perf probe --add 'tcp_sendmsg size' && perf record -e probe:tcp_sendmsg -a -- sleep 5
no commands match