Search code examples
cprofilingprofiler

Recommendations for C Profilers?


Everyone always says to profile your program before performing optimizations but no-one ever describes how to do so.

What are your practices for profiling C code?


Solution

  • Using gcc, I compile and link with -pg (as explained e.g. here), then continue by running the program (according to the principles also suggested at that URL) and using gprof. The tools will vary if you're using different compilers &c, but the URL is still recommended, even then, for the parts that are about general ideas on how and why to profile your code.