Profiling Programs

Linux Perf Tools (Linux)

Useful commands:

  • perf top - display top-like display but on function granularity
  • perf record PROGRAM - execute PROGRAM with profiling
  • perf report PROGRAM - display report for PROGRAM

Google Perftools (Linux, Mac Os X)

  • Download and install (also available through Ubuntu/Debian packages)
  • Compile your program with debug symbols (you probably want to enable optimization as well).
# Tell the profiler where to write its output.
google-pprof ${PROGRAM} ${OUT}

Interesting commands:

  • gv/web - display weighted call graph in gv or in your browser
  • top/topX - display top 10/X hitters
  • disasm NAME - disassemble functions matching NAME
comments powered by Disqus