gcc tools

Try using gcov -

If you want to find out where all your time is going, then gcov is for you. To use gcov you compile with some flags on, then run your program, then run gcov on the source file, it will create a new file that is the source file name with '.gcov' at the end. This file will tell you how many times each line ran. The compiler flags to use gcov are -fprofile-arcs -ftest-coverage. If you run gcov with a '-b' it will report percentages on every condition evaluated. There is another program gprof, but it doesn't give as much information.

This is no man page for gcov, so try this web site if you want more info:

gcov info from http://gcc.gnu.org/

Some compiler tricks you should know :

When you are all done and know everything works, you can still speed up your program. You add these to your Makefile when you build the final version of the program.

  • You will want to optimize your executable -
    • The -O3 setting on the gnu compiler turns all optimizations on. Don't develop your program this way, since it diasables some of the compiler warnings. The -O2 is pretty commonly used for distributed binaries.
  • Strip your binaries -
    • Run the strip command on your executables. This will remove the symbol tables, and reduce your executable size. It is removing information that you don't need unless you are debugging your code.