Yes, for VTune (or other similar profiling tools) you need "release build" (i.e. optimization switched ON) with debug information switched ON as well. QTCreator doesn't create this kind of release+debug configuration by default.
For Windows MS compiler toolchain case it implies that you have to supplement Release configuration with additional /Zi compilation and /DEBUG linker options.
In order to propagate these additional options in QTCreator use following steps (see also screen-shot below):
- Open qtcreator project file (***.pro) in editor
- Add following lines before "TARGET"
QMAKE_CXXFLAGS+=-Zi
QMAKE_LFLAGS+=/DEBUG
- Now, when building your project, these options will be automatically applied to both Debug and Release configuration (Debug already has it, so it should not be a problem)
- Now you can profile your release build using VTune
Few more minor notes:
- Similar procedure (with QMAKE_CXXFLAGS) is also applicable to MinGW/GCC or any other toolchains with appropriate options (-g, -gdwarf-2, etc)
- If you don't want to impact all configurations, there are QT project pragmas allowing to conditionalize QMAKE_CXXFLAGS between configurations
- If you want to profile QT standard libraries internals, then you will additionally have to link with debug versions of QT libraries, by adjusting QMAKE_LFLAGS with extra options like /DQT***; you can learn these from looking at QT "compiler output" window when building default Debug configurations.