perf
TLDR
Display performance stats for a command
SYNOPSIS
perf [stat|record|report|top|list] [options] [command]
DESCRIPTION
perf is the official Linux kernel profiling tool. It provides access to hardware performance counters, tracepoints, and software performance events. It's essential for identifying performance bottlenecks in applications and the kernel.
The tool can measure CPU cycles, cache misses, branch mispredictions, and many other low-level events. It supports both sampling-based profiling and event counting.
PARAMETERS
-p, --pid _pid_
Profile existing process by PID-e, --event _event_
Select specific events to measure-g
Enable call-graph recording-a
System-wide collection from all CPUs-o _file_
Output file name
COMMANDS
stat
Run command and gather performance counter statisticsrecord
Run command and record profile into perf.datareport
Read perf.data and display profiletop
System-wide real-time profilinglist
List available performance eventsannotate
Read perf.data and display annotated codediff
Compare two perf.data files
CAVEATS
Requires root or kernel.perfeventparanoid sysctl adjustment for many operations. Hardware counter availability varies by CPU. Profile data can be large. Some features require specific kernel configuration.
HISTORY
perf was developed as part of the Linux kernel, primarily by Ingo Molnar and Thomas Gleixner. It replaced the older OProfile tool and became the standard Linux profiling interface, integrated directly into the kernel source tree.


