I've used gprof, but never have had a lot of success with it. In all honestly, its probably my failure to learn to REALLY use it well. But it also requires compilation w/ -pg. What I recommend, if you can get yourself into the situation to use it, is Shark on a Mac. I know thats something of a special case, but it is an INCREDIBLE sampler. It makes it VERY easy to just run some code, look at the output, tweak it and run again. It makes iterative optimizing very easy. It also has a very nice GUI for browsing the time spent in various functions.
Its not installed by default, but part of the free CHUD downloads. I recommend it to anyone who can get their hands on it.
If you can't get that, then another linux suggestion (outside of gprof) is oprofile. Its newer than gprof, requires a kernel module, but its pretty nice. It can sample random running processes.
As far as memory tracking, theres always valgrind (which has a performance tool called cachegrind).
|