Profiling C Code with Gprof
Use Gnu Prof to find out how much CPU time is spent in each function and how often they are called.
First, compile the code with the -pg flag
Then, run the program as usual. It will produce a gmon.out file
Run gprof execname to view the output statistics (probably want to redirect or use less)