I assume you're using gcc/g++, in which case you may want to look at gprof, which is a part of the gcc package I think. You'll need to compile your binaries with profiling support (see the gcc/g++/gprof manpages).
If you do a search for gprof on
www.freshmeat.net, you'll see several graphical front-ends to help you analyse the results.