CFLAGS+=-fno-omit-frame-pointer -g
installed via sudo apt-get install libgoogle-perftools4
used as:
LD_PRELOAD=/usr/lib/libprofiler.so.0 CPUPROFILE=dump.txt ./bin/executable args ...
google-pprof --text ./bin/executable dump.txt > profile.txt
output looks like:
brentp@x1$ head profile.txt
Total: 4600 samples
1780 38.7% 38.7% 1780 38.7% uint_pair_sort_by_first_element_cmp
1419 30.8% 69.5% 3570 77.6% msort_with_tmp.part.0
393 8.5% 78.1% 393 8.5% memcpy
271 5.9% 84.0% 271 5.9% b_search (inline)
86 1.9% 85.8% 87 1.9% _int_malloc
80 1.7% 87.6% 80 1.7% inflateBackEnd
56 1.2% 88.8% 91 2.0% simple_cache_get
53 1.2% 90.0% 53 1.2% __GI_____strtol_l_internal
48 1.0% 91.0% 48 1.0% __write_nocancel
can also get a pdf call-graph with
google-pprof --pdf ./bin/executable dump.txt > dump.pdf
usage is like:
./bin/executable args ... &
sudo perf record -g -p `pidof executable` -o ./my.perf.data sleep 200
perf report --stdio -U -i ./my.perf.data | c++filt > profile.txt
output looks like:
$ head -30 perf | tail -n+10
# ........ ........ ....... ............. .........................................
#
44.39% 44.37% giggle giggle [.] uint_pair_sort_by_first_element_cmp
|
|--42.75%-- uint_pair_sort_by_first_element_cmp
| |
| gen8_irq_handler
| |
| |--0.02%-- gen8_gt_irq_handler
| | |
| | --0.01%-- intel_lrc_irq_handler
| | |
| | |--0.00%-- execlists_check_remove_request
| | | |
| | | --0.00%-- i915_gem_obj_ggtt_offset_view