perf commands

17 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 17 shown

  • perf record -g ./my_app

    Record performance data with call-graph info

    profiling · cpu · linux

  • perf report

    Interactive display of recorded perf data

    profiling · report

  • perf list

    List all supported perf events on current system

    profiling · events

  • perf stat ls -la

    Show hardware counters for a command

    profiling · stat

  • perf record -e cache-misses ./my_app

    Record only cache-miss events

    profiling · cache

  • perf top

    Show live per-function CPU usage (like top)

    profiling · top · live

  • perf annotate

    Show annotated assembly for hottest function

    profiling · annotate

  • perf record -F 99 -ag -- sleep 30 && perf script > out.perf

    Collect data suitable for flamegraph generation

    profiling · flamegraph

  • perf stat -e syscalls:sys_enter_read ./my_app

    Count specific syscall events

    profiling · syscalls

  • perf record -p 1234 sleep 5

    Profile an already-running process for 5 seconds

    profiling · attach · pid

  • perf top -g --call-graph dwarf

    Live top hot functions with caller chains; dwarf unwind works without frame pointers

    performance · debug · troubleshooting

  • perf record -F 99 -a -g -- sleep 30 && perf report --stdio

    Sample whole machine at 99Hz for 30s, then print collapsed report; 99Hz dodges lockstep aliasing

    performance · monitoring · troubleshooting

  • perf script | stackcollapse-perf.pl | flamegraph.pl > flame.svg

    Turn perf.data into an interactive flame graph SVG (Brendan Gregg FlameGraph tools)

    performance · observability · troubleshooting

  • perf stat -d -d -d -- ./app

    Run with three -d for L1/LLC/TLB and stalled-cycle detail; reveals memory-bound vs CPU-bound

    performance · monitoring · troubleshooting

  • perf sched record -- sleep 10 && perf sched latency --sort max

    Record context switches then show per-task wakeup latency; find runqueue starvation

    performance · kernel · troubleshooting

  • perf trace -s -p <pid>

    strace-like syscall trace with -s summary; lower overhead, no ptrace stop-the-world

    debug · performance · troubleshooting

  • perf probe --add 'tcp_sendmsg size' && perf record -e probe:tcp_sendmsg -a -- sleep 5

    Add a kprobe with an argument, then record it; inspect kernel internals without rebuilding

    kernel · debug · observability