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
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).
QTime [doc.qt.nokia.com] should do the trick too.
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
You must log in to post a reply. Not a member yet? Register here!



