Performance profiling on Linux

后端 未结 10 1887
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 23:40

What are the best tools for profiling C/C++ applications on *nix?

(I\'m hoping to profile a server that is a mix of (blocking) file IO, epoll for network and fork()/

相关标签:
10条回答
  • 2020-12-24 00:16

    Compile with -pg, run the program, and then use gprof

    Compiling (and linking) with -pg adds profiling code and the profiling libraries to the executable, which then produces a file called gmon.out that contains the timing information. gprof displays call graphs and their (absolute and relative) timings.

    See man gprof for details.

    0 讨论(0)
  • 2020-12-24 00:17

    oprofile might interest you. Ubuntu should have all the packages you need.

    0 讨论(0)
  • 2020-12-24 00:17

    Description of using -gp and gproff here http://www.ibm.com/developerworks/library/l-gnuprof.html

    0 讨论(0)
  • 2020-12-24 00:18

    For performance, you can try Callgrind, a Valgrind tool. Here is a nice article showing it in action.

    0 讨论(0)
提交回复
热议问题