I'm looking for the equivalent in Qt to
Something that will allow me to measure the time it takes for a segment of code to run as in:
uint start = GetTickCount(); // do something.. uint timeItTook = GetTickCount() - start;
QTime? Depending on your platform it should have 1 millisecond accuracy. Code would look something like this:
QTime myTimer; myTimer.start(); // do something.. int nMilliseconds = myTimer.elapsed();
I think it's probably better to use
QElapsedTimer since that is why the class exists in the first place. It was introduced with Qt 4.7. Note that it is also immuned to system's clock time change.
#include <QDebug> #include <QElapsedTimer> ... ... QElapsedTimer timer; timer.start(); slowOperation(); // we want to measure the time of this slowOperation() qDebug() << timer.elapsed();