4

I need help with profiling my C++ Qt application on target, both memory usage and cpu load. I was recomended gprof, but can't seem to get it to work. These are the guides I tried to follow:

I added these flags to my .pro file

QMAKE_CXXFLAGS+=-pg
QMAKE_LFLAGS+=-pg

But when I execute the program the gmon.out file is nowhere to be found?!

Can anyone give me a step-by-step example of what I am supposed to do?

Andy
  • 49,085
  • 60
  • 166
  • 233
A.Faur
  • 93
  • 2
  • 8

3 Answers3

2

Try:

QMAKE_CXXFLAGS_DEBUG *= -pg
QMAKE_LFLAGS_DEBUG *= -pg

instead of:

QMAKE_CXXFLAGS += -pg
QMAKE_LDFLAGS += -pg

and don't forget this:

CONFIG += debug

I had the same problem and it worked for me. Hope it helps!

pedromateo
  • 2,965
  • 1
  • 18
  • 19
1

try

QMAKE_CXXFLAGS+=-pg
QMAKE_LFLAGS+=-pg

http://www.qtcentre.org/wiki/index.php?title=Profiling_with_GNU_gprof

Andy
  • 49,085
  • 60
  • 166
  • 233
mpsido
  • 167
  • 4
0

I am profiling code running on an iMX-7 embedded device with GNU c++ compiler for ARM CPU. I have used that suggestion and it worked:

QMAKE_CXXFLAGS *= -pg
QMAKE_LFLAGS *= -pg

However, gprof output analysis showed 11 cycles (recursive calls) which didn't exist.

Adding more debug information at compile time (-Og) reduced cycle count from 11 to 7. Still not perfect but the remaining ones were benign:

QMAKE_CXXFLAGS *= -pg
QMAKE_CXXFLAGS += -Og
QMAKE_LFLAGS *= -pg