-
Notifications
You must be signed in to change notification settings - Fork 21
Profiling
Simon Ninon edited this page Mar 8, 2018
·
10 revisions
pprof helps diagnose which functions use most of the CPU resources.
Note that this works better by compiling lib with a test file rather than linking against it.
- compile with
-gand link with-lprofiler - run with
LDPRELOAD=/usr/lib/libprofiler.so CPUPROFILE=cpu.profile ./bin - run
google-pprof --text cpu.profile ./bin(switch to --gv, --pdf, --svg, ... depending on what output you prefer)
cachegrind helps diagnose data & instructions cache misses.
Note that this works better by compiling lib with a test file rather than linking against it.
- compile with
-g - run
valgrind --tool=cachegrind ./bin - run
cg_annotate cachegrind.out.xxxxto get a global report by file - run
cg_annotate cachegrind.out.xxxx /abs/path/to/file.cppto get a line-by-line report for a specific file - run
cg_annotate cachegrind.out.xxxx --auto=yesto get a full line-by-line report for all files
callgrind helps diagnose which instructions are executed the most.
Note that this works better by compiling lib with a test file rather than linking against it.
- compile with
-g - run
valgrind --tool=callgrind ./bin - run
callgrind_annotate callgrind.out.xxxxto get a global report by file - run
callgrind_annotate callgrind.out.xxxx --auto=yesto get a full line-by-line report for all files
Need more information? Open an issue.