Profiling with Google Performance Tools
Build Google Performance Tools
You should have a running version of graphviz on your system
=> Check dot -V
~ $ cd /data/foo /data/foo $ mkdir perftools /data/foo $ cd perftools /data/foo/perftools $ wget http://google-perftools.googlecode.com/files/google-perftools-1.1.tar.gz /data/foo/perftools $ tar xzf google-perftools-1.1.tar.gz /data/foo/perftools $ cd google-perftools-1.1 /data/foo/perftools/google-perftools-1.1 $ ./configure --prefix=/data/foo/perftools/1.1 /data/foo/perftools/google-perftools-1.1 $ make /data/foo/perftools/google-perftools-1.1 $ make install
With libunwind
./configure --prefix=/data/foo/perftools/1.5 CPPFLAGS=-I/data/foo/libunwind/include LDFLAGS=-L/data/foo/libunwind/lib
Using Google Performance Tools for CPU Profiling
Using Google Performance Tools for CPU Profiling (for the impatient)
- For best robustness link your executable to libprofiler.so
e.g. g++ -o mybinary mybinary.cpp myobj1.o -L /data/foo/perftools/1.1/lib -lprofiler
alternatively LD_PRELOADing works too:
export LD_PRELOAD=/data/foo/perftools/1.1/lib/libprofiler.so
- or e.g. on zsh (maybe bash?)
LD_PRELOAD=/data/foo/perftools/1.1/lib/libprofiler.so mybinary
- To do the profiling:
$ export CPUPROFILE=marlin.prof $ Marlin
- to get more samples (usually not needed; default is 100 Hz):
$ export CPUPROFILE=marlin.prof $ export CPUPROFILE_FREQUENCY=1000 $ Marlin
Get the results
$ /data/foo/perftools/1.1/bin/pprof --text /group/hcal/calice_soft/pro_test/Marlin/bin/Marlin marlin.prof $ /data/foo/perftools/1.1/bin/pprof --gv /group/hcal/calice_soft/pro_test/Marlin/bin/Marlin marlin.prof
* Too complex? Focus on the important:
$ /data/foo/perftools/1.1/bin/pprof --gv --focus marlin::ProcessorMgr::end /group/hcal/calice_soft/pro_test/Marlin/bin/Marlin marlin.prof