在Linux上使用c++的profiler容易吗?

时间:2022-09-06 18:47:01

I need to profile some code running C++ on Linux. Can you guys recommend some profilers?

我需要分析一些在Linux上运行c++的代码。你们能推荐一些剖析器吗?

9 个解决方案

#1


35  

Use gprof.

使用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.

只需使用-pg标志(我认为(但不确定)编译就可以了),然后使用gprof分析gmon。您的可执行文件随后将生成的文件。

eg:

例如:

gcc -pg -o whatever whatever.c

./whatever

gprof whatever gmon.out

Same thing with g++ and cpp.

g++和cpp也是一样。

#2


17  

valgrind is a well-know linux profiler

valgrind是一个众所周知的linux剖析器

#3


13  

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.

我一直在使用RotateRight (http://www.rotateright.com)。它有一个功能的蝴蝶视图,您可以双击任何功能,深入到源代码或asm代码中。使用调试信息(-g)构建以查看源代码,但仍然应该构建和配置优化代码。

#4


11  

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.

我是Oprofile的粉丝。它涉及到安装内核模块,并对其进行了一些学习,但是它非常强大,而且对于没有调试符号的优化程序/程序非常有效。

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

Vtune是英特尔制造的另一个非常强大的分析器。我相信Linux版本对于非商业软件是免费的。

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.

还有dfa提出的Valgrind工具套件。Callgrind很可能是你最感兴趣的东西。Cachegrind(其特性集是Callgrind的一个子集)和Massif也很有趣,但是我对后者毫无经验。

#5


5  

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

看一下KCacheGrind函数,它是一种图形化的图形化的图形化的前端,使它非常容易使用。

#6


4  

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

谷歌也有一个不错的剖析器,作为Google性能工具的一部分——它包含在Debian / Ubuntu中,也可能包含在其他发行版中。

#7


2  

gprof is the standard gnu tool for profiling.

gprof是用于分析的标准gnu工具。

#8


2  

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

看看Sysprof。您的发行版很可能已经有了它。

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.

请注意,如果您的应用程序是用框架指针编译的,那么所有的profiler都是最有效的。也就是说,您应该在gcc命令行中使用-fno-omit-frame指针。

#9


1  

This is what I use.

这就是我用的。

#1


35  

Use gprof.

使用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.

只需使用-pg标志(我认为(但不确定)编译就可以了),然后使用gprof分析gmon。您的可执行文件随后将生成的文件。

eg:

例如:

gcc -pg -o whatever whatever.c

./whatever

gprof whatever gmon.out

Same thing with g++ and cpp.

g++和cpp也是一样。

#2


17  

valgrind is a well-know linux profiler

valgrind是一个众所周知的linux剖析器

#3


13  

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.

我一直在使用RotateRight (http://www.rotateright.com)。它有一个功能的蝴蝶视图,您可以双击任何功能,深入到源代码或asm代码中。使用调试信息(-g)构建以查看源代码,但仍然应该构建和配置优化代码。

#4


11  

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.

我是Oprofile的粉丝。它涉及到安装内核模块,并对其进行了一些学习,但是它非常强大,而且对于没有调试符号的优化程序/程序非常有效。

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

Vtune是英特尔制造的另一个非常强大的分析器。我相信Linux版本对于非商业软件是免费的。

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.

还有dfa提出的Valgrind工具套件。Callgrind很可能是你最感兴趣的东西。Cachegrind(其特性集是Callgrind的一个子集)和Massif也很有趣,但是我对后者毫无经验。

#5


5  

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

看一下KCacheGrind函数,它是一种图形化的图形化的图形化的前端,使它非常容易使用。

#6


4  

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

谷歌也有一个不错的剖析器,作为Google性能工具的一部分——它包含在Debian / Ubuntu中,也可能包含在其他发行版中。

#7


2  

gprof is the standard gnu tool for profiling.

gprof是用于分析的标准gnu工具。

#8


2  

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

看看Sysprof。您的发行版很可能已经有了它。

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.

请注意,如果您的应用程序是用框架指针编译的,那么所有的profiler都是最有效的。也就是说,您应该在gcc命令行中使用-fno-omit-frame指针。

#9


1  

This is what I use.

这就是我用的。