• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

perf Command Examples in Linux

by Deepika

perf is a Linux tool that measures performance-related data in a variety of ways, including hardware performance counters and tracepoints. It provides an interface for analyzing the performance of the operating system, applications, and other system components.

The perf tool is built into the Linux kernel, and it can be used to collect and analyze performance data in a number of ways. For example, it can be used to count the number of CPU cycles consumed by a particular process, or to monitor memory accesses and cache misses. It can also be used to trace events in the system, such as function calls and context switches.

One of the main advantages of perf is that it provides a unified interface for accessing performance data, making it easier for developers and performance engineers to work with performance-related data. Additionally, perf is extensible, meaning that it can be extended to support new performance counters and tracepoints as they become available.

perf Command Examples

1. Display basic performance counter stats for a command:

# perf stat gcc hello.c

2. Display system-wide real-time performance counter profile:

# sudo perf top

3. Run a command and record its profile into `perf.data`:

# sudo perf record command

4. Record the profile of an existing process into `perf.data`:

# sudo perf record -p pid

5. Read `perf.data` (created by `perf record`) and display the profile:

# sudo perf report

Summary

Overall, perf is a valuable tool for performance analysis and optimization on Linux systems, and it is widely used by developers and performance engineers to understand the behavior of their systems and to identify performance bottlenecks.

Filed Under: Linux

Some more articles you might also be interested in …

  1. pacman –sync Command Examples
  2. pvs: command not found
  3. csvsql: Generate SQL statements for a CSV file or execute those statements directly on a database
  4. aws kinesis: Official AWS CLI for Amazon Kinesis streaming data services
  5. etckeeper: command not found
  6. latte-dock Command Examples in Linux
  7. pulseaudio Command Examples in Linux
  8. whois: command not found
  9. How to Move Swap From Disk Partition to LVM Volume in Linux
  10. pulseaudio: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright