What is a good easy to use profiler for C++ on Linux? [closed]

做~自己de王妃 提交于 2019-11-27 10:36:05
smcameron

Use gprof.

Just compile with -pg flag (I think (but am not sure) you have to turn of optimizations though.) and use gprof to analyze the gmon.out file that your executable will then produce.

eg:

gcc -pg -o whatever whatever.c

./whatever

gprof whatever gmon.out

Same thing with g++ and cpp.

valgrind is a well-know linux profiler

Zoom from RotateRight ( http://www.rotateright.com ) is what I've been using. It has a butterfly view of functions and you can double-click any function to dive into source or asm code. Build with debugging information (-g) to see your source, but you should still build and profile optimized code.

I'm a fan of Oprofile. It involves installing a kernel module and has a bit of a learning curve to it, but it's fairly powerful and works very well for optimized programs/programs without debugging symbols.

Vtune is another very powerful profiler made by Intel. I believe the Linux version is free for Non-commercial software.

There is also the Valgrind suite of tools proposed by dfa. Callgrind would probably be what you're most interested in. Cachegrind(whose featureset is a subset of Callgrind's) and Massif are interesting as well, but I have no experience with the latter.

Take a look at KCacheGrind which is a graphical frontend to valgrind and makes it really easy to use it.

Dirk Eddelbuettel

Google also has a nice profiler as part of the google-perftools -- which are included in Debian / Ubuntu and possibly other distros.

gprof is the standard gnu tool for profiling.

Take a look at Sysprof. You distribution most likely has it available already.

Note that all of the mentioned profilers work best if your application is compiled with frame pointers. That is, you should use -fno-omit-frame-pointer on the gcc command line.

Mike Dunlavey
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!