Sample CPU Usage With perf record
Record call graphs, then inspect hotspots with perf report.
01Command
$ perf record -g -- ./my-program02What it does
perf record samples the stack at intervals and writes a data file that perf report or a flame-graph tool turns into hotspots. It answers where time is actually spent without modifying the program, and it is inherently a script and terminal workflow.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- perf-record.1.en.html manual page (Debian bookworm)Evidence: Documents perf record sampling and call-graph collection.
Last verified: 2026-10-13 · Category: System & Settings
06Related solutions
Launch an interactive process viewer with color meters for CPU cores, memory, and swap, plus search, sort, and kill controls.
Show every TCP and UDP socket in listening state with the owning process name and PID — the modern replacement for netstat.
Show every systemd unit currently in a failed state, so you can inspect and restart whatever broke.