Reputation: 11733
I am with Qt 4.8, and try to be cross platform (at least on linux and mac).
I need to visualize in the gui how much times an operation takes. I have tried with:
QTime t;
t.start();
functionCall();
qDebug() << t.elapsed() << "ms";
But I've read that it is not reliable. Some alternatives?
Sorry, no C++0x
Upvotes: 0
Views: 1115
Reputation: 22734
That's not reliable and not very accurate. Use QElapsedTimer instead.
Of course, both QTime and QElapsedTimer measure wall clock time. You need QtTest and QBENCHMARK in order to get other measures (callgrind, CPU tick counters, etc.), see also the QTest::setBenchmarkResult function.
Upvotes: 3