I am using Eclipse CDT under Linux, can anyone recommend a good profiler under that environment please.
I am also new to C++ and multi-thread programming, can anyone also offer some advice on how to run profiling for multi-threaded application please, e.g., what to look for performance bottleneck, etc.
Thanks.
I don't know if it's best choice, but it's definitely obvious one: gprof. You just need to set compilation switches right (enable gprof (-pg) for that project in project properties -> c/c++ build -> Settings -> Debugging).
When you have compiled program with this options, you need to run it (until in normally exits). This generates profile file (gmon.out).
There is additional plug-in you can install in eclipse, that visualizes the contents of gmon.out (go to Help -> Install -> Linux tools -> GProf integration). Just open generated gmon.out file as you would any other file, once you have that plugin installed.
As mentioned by dbrank0 you need to set the compilation option (-pg) for that project. Go to project properties -> c/c++ build -> Settings -> C++ compiler -> Debugging and check generate gpof information. When you compile the program(test_prof.c) you will get an exe file(in our case test_prof).
$ ls
test_gprof test_gprof.c
and when you run it there will be a gmon.out file generated in the same directory.
$ ls
gmon.out test_gprof test_gprof.c
The gprof tool is run with the executable name and the above generated ‘gmon.out’ as argument. This produces an analysis file which contains all the desired profiling information.
$ gprof test_gprof gmon.out > analysis.txt
A file named ‘analysis.txt’ will be generated which contains all the profilig information and can be easily read out.
For further details look at http://www.thegeekstuff.com/2012/08/gprof-tutorial/