gprof
From Cppwiki
gprof is the standard Unix profiler. It produces basic performance reports including call counts, timing information and descendent information for called functions.
Using gprof
$ cc -pg program.c -o program $ ./program $ gprof ./program
In order for the profiling data (gmon.out) to be written, the program must either exit or return from main. Other exit methods, such as exits from signals (including SIGINT or SIGTERM, generated by typing ^C), will not emit profiling information correctly.