1
2# Note that you must do all the following as root (I believe).
3# Although the program to be profiled can be run by anybody.
4
5# start the profiler
6opcontrol --stop ; opcontrol --reset ; opcontrol --callgraph=5 --start
7
8# now run the program(s) to be profiled
9
10# stop the profiler and dump results to .. um .. some file somewhere
11opcontrol --stop ; opcontrol --dump
12
13# get total cost
14opreport --merge=tgid -x \
15    /home/sewardj/VgTRUNK/atomk/Inst/lib/valgrind/helgrind-amd64-linux \
16    | less
17
18# produce a flat profile
19opreport --merge=tgid --symbols -x \
20    /home/sewardj/VgTRUNK/atomk/Inst/lib/valgrind/helgrind-amd64-linux \
21    | less
22
23# produce a profile w/ callgraph
24opreport --merge=tgid --callgraph -x \
25    /home/sewardj/VgTRUNK/atomk/Inst/lib/valgrind/helgrind-amd64-linux \
26    | less
27
28# print annotated source
29opannotate --merge=tgid --source --include-file=libhb_core.c | less
30
31
32#### notes.
33
341. on amd64, need to build V with -fno-omit-frame-pointer, else the
35   w/ callgraph profiles are useless.  (oprofile doesn't do CFI based
36   stack unwinding, I guess).  Add -fno-omit-frame-pointer to
37   AM_CFLAGS_BASE in Makefile.flags.am, and rebuild from clean.
38
392. even at the best of times the callgraph profiles seem pretty
40   flaky to me.
41
423. Even oprofile 0.9.4 (the latest) on amd64-linux doesn't work
43   for callgraph profiling.  There is however a patch that
44   makes it work.  See
45
46http://sourceforge.net/tracker/index.php?func=detail&aid=1685267&group_id=16191&atid=116191
47
48   for details.  Even then it sometimes fails at the "opcontrol
49   --dump" phase, complaining that the daemon died (or something like
50   that).  But apart from that, it seems usable.
51