The perf command in Red Hat-based Linux distributions is a powerful tool used for performance analysis and profiling of applications and the system. It provides insights into various aspects of system performance, including CPU usage, memory usage, disk I/O, and more. Here’s a table with information and examples related to the perf command:
| Command | Description | Example |
|---|---|---|
perf record | Record events for a specified command | perf record ls |
perf report | Generate a report from recorded data | perf report |
perf top | Display live summary of top events | perf top |
perf stat | Display statistics for a specified command | perf stat ls |
perf record -e | Record specific events for a specified command | perf record -e cpu-cycles ls |
perf script | Generate a script from recorded data for custom analysis | perf script |
perf record -F | Record events with a specified frequency | perf record -F 99 sleep 5 |
perf mem | Memory profiling using hardware counters | perf mem record ls |
Examples:
- Record events for a specific command:
Bash
perf record ls- Generate a report from recorded data:
Bash
perf report- Display live summary of top events:
Bash
perf top- Display statistics for a specified command:
perf stat ls
- Record specific events for a specified command:
perf record -e cpu-cycles ls
- Generate a script from recorded data for custom analysis:
Bash
perf script- Record events with a specified frequency (e.g., 99 Hz) for a command:
Bash
perf record -F 99 sleep 5- Perform memory profiling using hardware counters:
Bash
perf mem record lsKeep in mind that the perf tool provides a wide range of capabilities, and the examples above cover only a fraction of its features. The tool offers detailed insights into the performance of your system and applications, but understanding and interpreting its output may require some familiarity with performance analysis concepts.