perf is a performance analyzing tool for Linux-based systems. Available via command-line interface, it is capable of statistical profiling of the entire system (both kernel and user code).


  • To list the supported commands, execute

     usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
     The most commonly used perf commands are:
       annotate        Read (created by perf record) and display annotated code
       archive         Create archive with object files with build-ids found in file
       bench           General framework for benchmark suites
       buildid-cache   Manage build-id cache.
       buildid-list    List the buildids in a file
       config          Get and set variables in a configuration file.
       data            Data file related processing
       diff            Read files and display the differential profile
       evlist          List the event names in a file
       inject          Filter to augment the events stream with additional information
       kmem            Tool to trace/measure kernel memory properties
       kvm             Tool to trace/measure kvm guest os
       list            List all symbolic event types
       lock            Analyze lock events
       mem             Profile memory accesses
       record          Run a command and record its profile into
       report          Read (created by perf record) and display the profile
       sched           Tool to trace/measure scheduler properties (latencies)
       script          Read (created by perf record) and display trace output
       stat            Run a command and gather performance counter statistics
       test            Runs sanity tests.
       timechart       Tool to visualize total system behavior during a workload
       top             System profiling tool.
       probe           Define new dynamic tracepoints
       trace           strace inspired tool

    Certain commands require special support in the kernel and may not be available.

  • To obtain the list of options for each command, simply type the command name followed by -h:

    perf record -h


  • There are several commands associated with sampling: record, report and annotate. You must first collect the samples using perf record. This generates an output binary file called That file can then be analyzed, possibly on another machine, using the perf report and perf annotate commands.

    perf record -F 1000 --call-graph dwarf -e cycles:u ./program
    perf report

    By default, samples are sorted by functions with the most samples first.

results matching ""

    No results matching ""