September 14, 2011

suma suma
Lab Rat
36 posts

Execution time of the particular function

 

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

Thanks.

6 replies

September 14, 2011

Lukas Geyer Lukas Geyer
Lab Rat
2074 posts

You can use QElapsedTimer [doc.qt.nokia.com] or Q_BENCHMARK [doc.qt.nokia.com] of the QtTest [doc.qt.nokia.com] module, which allows for measuring various performance metrics (Walltime, tick counter, Valgrind/Callgrind, Event Counter).

September 14, 2011

suma suma
Lab Rat
36 posts

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

September 14, 2011

Lukas Geyer Lukas Geyer
Lab Rat
2074 posts

QTime [doc.qt.nokia.com] should do the trick too.

September 14, 2011

suma suma
Lab Rat
36 posts

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

September 14, 2011

Andre Andre
Robot Herder
6417 posts

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:

  1. QTime timer;
  2. timer.start()
  3. myLongFunction();
  4. int runtime = timer.elapsed(); //gets the runtime in ms

September 14, 2011

suma suma
Lab Rat
36 posts

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

 
  ‹‹ [Solved]setup add-in to visual studio      QTCreator 2.3.0 debugger detects wrong ABI. ››

You must log in to post a reply. Not a member yet? Register here!