[Qt-creator] Macros for profiling
Nikolai Kosjar
nikolai.kosjar at digia.com
Tue Mar 12 15:35:40 CET 2013
Hiya!
I want to introduce some simple macros for profiling:
https://codereview.qt-project.org/#change,49842
WIP, Documentation/Examples included
Basically, there are macros that record how often and how long an object
existed on the stack and macros that just log the elapsed time since
previous log calls.
By default, profiling support is disabled (it is a #define in
utils/profiler.h) and thus the macros expand to nothing.
If you have objections or further suggestions, just step up :)
How to use:
0. Link against libUtils in your project where necessary
(mostly it's already linked)
1. Explicitly enable profiling support in utils/profiler.h.
2. Add "#include <utils/profiler.h>" to the relevant files and
instrument your code with the Macros (see examples in the doc)
3. Compile & Run Qt Creator - depending on the used macros some output
might be generated during run time.
4. Quit Qt Creator - on shutdown a summary is printed.
Motivation:
1. With this, you can create a patch of your instrumented code and send
it your colleague in order to compare the resulting numbers. Of course,
this becomes superfluous from the point a cross platform profiler with
easy sharing of the instrumentation appears.
2. I plan to use some macros in the auto and plugin tests since lately
there were some performance slowdowns in e.g. the C++ Support area. The
profiling output can be also written to a log file. Having some
"reference" output for certain tests would certainly be quite nice when
reviewing patches that deal with template instantiations etc... I know
there is QBENCHMARK(_ONCE), but I would prefer to have the profiling
output on demand and besides this does not solve point 1 in a broader sense.
Nikolai
More information about the Qt-creator
mailing list