perf
is a powerful Linux command-line performance analysis tool. It provides a way to collect and analyze various performance-related data, such as CPU utilization, memory usage, cache misses, and more. perf
is included with the Linux kernel, making it readily available on most Linux distributions.
Here are some common and useful subcommands and options of perf
:
-
perf stat: Collect and display various performance statistics such as instructions executed, cache misses, CPU cycles, etc. Example:
perf stat -e instructions -e cache-references ./my_program
. -
perf record: Record performance events for later analysis. Example:
perf record -e cache-misses ./my_program
. -
perf report: Analyze and display a report based on data collected by
perf record
. Example:perf report
. -
perf top: Display real-time performance statistics in a top-like interface. Example:
perf top
. -
perf annotate: Annotate source code with performance data. Example:
perf annotate -d ./my_program
. -
perf trace: Trace events such as system calls, context switches, or other events. Example:
perf trace -e syscalls:sys_enter_open
. -
perf list: List available performance events and event attributes. Example:
perf list
. -
perf help: Display help information about
perf
and its subcommands. Example:perf help
.
https://arxiv.org/pdf/2112.09981
How can I install perf for Linux kernel 6.1.0-060100-generic on Ubuntu? - Stack Overflow