Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt profiler
Qt 6.11 is out! See what's new in the release blog

Qt profiler

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.
      Like
      #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();
          function();
          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
          DEFINES += QT_NO_DEBUG_OUTPUT
      } else {
          #This is a debug build
      }
      

      and in the code use

      #ifndef QT_NO_DEBUG_OUTPUT
       what ever to do when in debug build
      #endif
      
      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thank you , will try those examples.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved