Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Execution time of the particular function
Forum Updated to NodeBB v4.3 + New Features

Execution time of the particular function

Scheduled Pinned Locked Moved Qt Creator and other tools
7 Posts 3 Posters 6.5k Views 1 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.
  • S Offline
    S Offline
    suma
    wrote on last edited by
    #1

    Hi,
    Is there any tool to find out the execution time of the particular function in qt.

    Thanks.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      You can use "QElapsedTimer":http://doc.qt.nokia.com/latest/qelapsedtimer.html or "Q_BENCHMARK":http://doc.qt.nokia.com/latest/qtest.html#QBENCHMARK of the "QtTest":http://doc.qt.nokia.com/latest/qtest.html module, which allows for measuring various performance metrics (Walltime, tick counter, Valgrind/Callgrind, Event Counter).

      1 Reply Last reply
      0
      • S Offline
        S Offline
        suma
        wrote on last edited by
        #3

        Hi,
        Thanks for fast reply.Im using Qt 4.4 but those classes are introduced in 4.7. Any other solution?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          "QTime":http://doc.qt.nokia.com/latest/qtime.html#elapsed should do the trick too.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            suma
            wrote on last edited by
            #5

            This i have tried out. It ll be fine if i get any tool to do this work.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              What is your ultimate goal? Do you want to hunt for bottlenecks in your application, or are you actually interested in the time a function took at runtime when the application is on your user's machine? In the first case, I suggest you use a tool like valgrind instead. In the second case, QTime will do just fine. Just do something like this:

              @
              QTime timer;
              timer.start()
              myLongFunction();
              int runtime = timer.elapsed(); //gets the runtime in ms
              @

              1 Reply Last reply
              0
              • S Offline
                S Offline
                suma
                wrote on last edited by
                #7

                Hi,
                Thank u very much. I ll find more about that tool.

                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