Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 820
shergill Avatar asked Jul 22 '09 23:07

shergill


People also ask

What is profiler in Linux?

Linux Profiling tools and techniques. Profiling is an alternative to benchmarking that is often more effective, as it gives you more fine grained measurements for the components of the system you're measuring, thus minimising external influences from consideration.

What is a profiler C?

The C Profiler tool enables the collection and display of execution profile data on C software source code bases of arbitrary size. It is a member of SD's family of Profiler tools.

Is Gprof open source?

Code Profiling in Linux Using Gprof - Open Source For You.


Video Answer


2 Answers

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.

like image 169
smcameron Avatar answered Oct 09 '22 16:10

smcameron


valgrind is a well-know linux profiler

like image 32
dfa Avatar answered Oct 09 '22 18:10

dfa