• 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. resize2fs Command Examples in Linux
  2. cewl Command Examples in Linux
  3. firewall-cmd: command not found
  4. git daemon: A really simple server for Git repositories
  5. pdfxup Command Examples in Linux
  6. watch Command Examples in Linux
  7. pluma Command Examples in Linux
  8. btrfs rescue Command Examples in Linux
  9. taskset Command Examples in Linux
  10. apt-cache: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright