Important: Please read the Qt Code of Conduct -

Qt profiler

  • Hello,
    Id like to analyse runtimes of functions in c++ app, qt offers qt analyser , is there way to see runtimes of functions or easyer to use timer code and qdebug?
    But is there any argument to make code so that some parts of code only in debug mode , not in relase?
    It would be useful for profiling app performance and not needing to edit code on relase.

  • Lifetime Qt Champion

    @Q139 said:

    Hi never used Qt Analyser.

    If only a few functions to analyse and you can use c++11
    then the new timing function works really well.
    #include <iostream>
    #include <chrono>

    using namespace std;
    using namespace std::chrono;
    void function()
        long long number = 0;
        for( long long i = 0; i != 2000000; ++i )
           number += 5;
    int main()
        high_resolution_clock::time_point t1 = high_resolution_clock::now();
        high_resolution_clock::time_point t2 = high_resolution_clock::now();
        auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
        cout << duration;
        return 0;

    and in your .pro file you can do

    CONFIG(release, debug|release) {
        #This is a release build
    } else {
        #This is a debug build

    and in the code use

    #ifndef QT_NO_DEBUG_OUTPUT
     what ever to do when in debug build

  • Thank you , will try those examples.

Log in to reply