Profiling Programs
Linux Perf Tools (Linux)
Requires
echo '-1' > /proc/sys/kernel/perf_event_paranoidas root.
Useful commands:
perf top- displaytop-like display but on function granularityperf record PROGRAM- execute PROGRAM with profilingperf report PROGRAM- display report for PROGRAM
Google Perftools (Linux, Mac Os X)
Download and install https://code.google.com/p/gperftools/ (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.
export CPUPROFILE=${OUT}
LD_PRELOAD="/usr/lib/libprofiler.so.0" ${PROGRAM} ${COMMAND_LINE}
google-pprof ${PROGRAM} ${OUT}
Interesting commands:
gv/web- display weighted call graph in gv or in your browsertop/topX- display top 10/X hittersdisasm NAME- disassemble functions matching NAME
Instruments (Mac Os X)
Todo
Write me!