开发者

Benchmarking (gprof) C++ program. Using eclipse environment

Well I've the following problem.

Facts; - Using eclipse - Using MinGW

I wanted to benchmark my created C++ program. I searched google and then came; http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html

I then wanted to add the "-pg" build command. But how/where do I add it? I went in to the "properties - C/C++ build - Discovery Options" and added it to the "Compiler invocation command" (http://img515.imageshack.us/img515/3159/678263开发者_JAVA技巧49.png) but it did nothing, as far as I can see in the console.

So what am I doing wrong?


under proprieties of the your project go to settings under c/c++ build hen on the right hand of the settings box go to tool settings under gcc c++ compiler you find debbuging there you find the option to generate gprof information


Note that you need to use -pg also while linking.


Move the "-pg" from the "compiler invocation command", into the "Compiler invocation arguments"


If it is a Makefile based project, make sure you add -pg to the CXXFLAGS variable in the Makefile. This will ensure that everything needed for profiling (more than the usual debug symbols) is built into the object files. You also will need to add -pg to the line where the executable is created. Chances are that it will look like the following:

$(CXX) -o $(TARGET) $(OBJS) $(LIBS)

You will want to add in the -pg there. That will make sure that the profiling information is also built into the executable. Now a gmon.out file should be produced when you run the program. It will only be produced if the program exits normally though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜