Good c++ profiler for GCC

2019-02-03 16:28发布

I tried to find a related question but all previous questions are about profilers for native c++ in windows. I googled a while and learned about gprof, but the output of gprof actually contained lot of obscure internal functions. Is there a good opensource c++ profiler with good documentation?

标签: c++ profiling
6条回答
啃猪蹄的小仙女
2楼-- · 2019-02-03 17:02

Compile using the flag -pg and use gprof.

查看更多
smile是对你的礼貌
3楼-- · 2019-02-03 17:12

I've heard oprofile is really, really good for real time apps. Linux only though, AFAIK.

查看更多
老娘就宠你
4楼-- · 2019-02-03 17:16

How much detail do you need in your profile reports. If you just want to do some really simple time profiling for a few functions, then the new functionality available via the C++11 chrono classes makes it easy to profile in a cross platform, cross compiler way.

See this article for some simple profiling code that works similarly to Matlab's super easy to use tic and toc functions.

查看更多
唯我独甜
5楼-- · 2019-02-03 17:20

Don't use gprof, for the reasons given here.

What you need are stackshots, explained here. One way to take stackshots is the pstack utility. Another way is to use "Pause" or ctrl-break under the debugger. Also lsstack, if you can get a copy.

If you want to spend money, RotateRight makes a nice tool based on stack sampling called Zoom.

查看更多
Animai°情兽
6楼-- · 2019-02-03 17:21

Valgrind

I totally recommend this http://en.wikipedia.org/wiki/Valgrind

查看更多
对你真心纯属浪费
7楼-- · 2019-02-03 17:28

If you don't mind the KDE library dependencies, KCachegrind is very useful with the added visualization. It depends on Callgrind and Valgrind, as one could have guessed, so no special compiler flags required during compile-time.

查看更多
登录 后发表回答