-
Notifications
You must be signed in to change notification settings - Fork 2
Profiling with google perftools
Janus Troelsen edited this page Jul 6, 2017
·
2 revisions
As an alternative to profiling with gprof, you can use google-perftools as follows:
- Install google-perftools. Either grab it from http://code.google.com/p/gperftools/ or in Ubuntu:
$ sudo apt-get install google-perftools libgoogle-perftools-dev
-
Run the tool you want to profile with a couple of extra environment variables:
- LD_PRELOAD should contain /usr/lib/libprofiler.so for CPU profiling and /usr/lib/libtcmalloc.so for heap profiling.
- CPUPROFILE should contain the name of the file to write CPU profiling data to if you want to do CPU profiling.
- HEAPPROFILE should contain the name of the file to write heap profiling data to if you want to do heap profiling.
So for example:
$ LD_PRELOAD=/usr/lib/libprofiler.so CPUPROFILE=cpu_profile ./cbmc my_test_program.c
or
$ LD_PRELOAD=/usr/lib/libtcmalloc.so HEAPPROFILE=heap_profile ./cbmc my_test_program.c
-
Visualize your profile using
pprof
, as described at http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html:
$ google-pprof --gv cpu_profile cbmc