Both tools are linux performance and profiling probing tool. I found that "perf" looks more powerful as it could trace into kernel call level. So my question is, with "perf", is there still a need to learn and keep "gprof"/
I mean, is there any work that only with gprof that could be done, while perf doesn't work well?
gprof
(several implementations for different OS) works with instrumentation of the program (requires recompilation) and with statistical PC sampling on interval timer signal (setitimer, up to 0.1-1 kHz). By instrumentation it get information about calls between functions and function call counts. Check https://en.wikipedia.org/wiki/Gprof:
Gprof is a performance analysis tool for Unix applications. It uses a hybrid of instrumentation and sampling[1] and was created as extended version of the older "prof" tool. Unlike prof, gprof is capable of limited call graph collecting and printing.[1][2]
perf
is Linux-only modern tool for statistical profiling. It can sample PC and call stacks (if there are frame pointers or enough debug information to unwind call stack) both on software timers and on hardware performance counters (like instruction executed, L1 miss count, and many other; full event list by showevtinfo
is http://www.bnikolic.co.uk/blog/hpc-prof-events.html, found in https://stackoverflow.com/a/23965237). There are other modes built into perf too: http://www.brendangregg.com/perf.html
So, gprof
can show you exact function call count of single program, but it can't resolve call stack (it only approximate it). And there are gprofs in Linux, BSD, and many other Unixes and Unix-like OS. perf
is Linux-only, but have access to hardware performance monitoring unit and support both single-program profiling and system-wide profiling.