Profiling programs

Profiling using operf

  1. Ensure you have access to your kernel’s debug symbols. On Fedora, you can install these symbols with sudo debuginfo-install kernel.
  2. Run sudo operf --system-wide --vmlinux /usr/lib/debug/lib/modules/KERNEL-VERSION/vmlinux, execute your experiments, and press Ctrl-C.
  3. Run opreport -l.

Profiling using gprof

Run a program and its children while collecting profiling data:

  1. Compile with GCC’s -pg flag.
  2. Run with GMON_OUT_PREFIX=prefix ./a.out.
  3. Run gprof a.out prefix.PID.