Benchmarking (gprof) C ++. Using the eclipse Environment

Well, I have the following problem.

Facts; - Using eclipse - Using MinGW

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

Then I wanted to add the build command "-pg". But how / where to add it? I went into "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 on the console.

So what am I doing wrong?

+4
source share
4 answers

according to your projects go to settings in c / C ++ build on the right side of the settings window go to tool settings in gcc C ++ compiler you will find that there debubuging you will find the ability to generate gprof information

+3
source

Note that you need to use -pg when linking.

+2
source

Move "-pg" from the "compiler invocation command" to "compiler invocation arguments"

+1
source

If this is a Makefile project, make sure you add -pg to the CXXFLAGS variable in the Makefile. This ensures that everything necessary for profiling (more than regular debugging symbols) is embedded in object files. You will also need to add -pg to the line where the executable will be created. Most likely, it will look like this:

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

You want to add -pg there. This will ensure that profiling information is also embedded in the executable. Now, when the program starts, the gmon.out file must be created. It will be created only if the program usually crashes.

+1
source

Source: https://habr.com/ru/post/1301849/


All Articles