Perf

Back

perf record

# Record performance
perf record -g <your program>

# Sample every 100 Hz
perf record -F 100 <prog>

# Performance Report
perf report -g

# Performance Report
# graph - type of call graph: normalize percentage used to adjacent frame
# 0.5 - filter percentage
# caller - invert call order of the graph
perf report -g 'graph,0.5,caller'

# fractal - percentages are relative to parent
perf report -g 'fractal,0.5,caller'

perf report -g 'graph,0.5,caller' -F+srcline,period

perf report -g --percent-limit 4


  • -g record call stack
    • Compile your program with -fno-omit-frame-pointer

perf report TUI

  • a - switch to compiled ASM
  • while in ASM window s for source code, k for line number
  • h for help

perf script

Walk through perf file and output contents of each record
perf script > out.perf

Further Reading