nkint
nkint

Reputation: 11733

Easiest way to test how much time an operation takes in Qt

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

Answers (1)

peppe
peppe

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

Related Questions