简体   繁体   中英

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/67826349.png ) but it did nothing, as far as I can see in the console.

So what am I doing wrong?

根据您项目的优点,在设置框右侧的c / c ++ build hen下进行设置转到gcc c ++编译器下的工具设置你发现在那里找到了生成gprof信息的选项

请注意,链接时也需要使用-pg。

将“-pg”从“编译器调用命令”移动到“编译器调用参数”

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM