diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-18 17:27:45 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-17 10:54:17 (GMT) |
commit | cd33d38ce0067719b0215264a22685a91b2e08dc (patch) | |
tree | 6dce3760c20b9631ca3be96b59bc0351381cedcb | |
parent | 8c9446cd2058fde086df92f6b7d97e4770cf8dc6 (diff) | |
download | Qt-cd33d38ce0067719b0215264a22685a91b2e08dc.zip Qt-cd33d38ce0067719b0215264a22685a91b2e08dc.tar.gz Qt-cd33d38ce0067719b0215264a22685a91b2e08dc.tar.bz2 |
Port QtCore uses of QTime as a stopwatch to QTimestamp.
tst_qtimeline improvement: from 56187446 to 53915928 (callgrind)
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 1 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 57 | ||||
-rw-r--r-- | src/corelib/io/qprocess.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 8 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qtimeline.cpp | 4 |
6 files changed, 14 insertions, 66 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index f834a80..82b3003 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -170,6 +170,7 @@ QUnifiedTimer::QUnifiedTimer() : currentAnimationIdx(0), consistentTiming(false), slowMode(false), isPauseTimerActive(false), runningLeafAnimations(0) { + time.invalidate(); } QUnifiedTimer *QUnifiedTimer::instance() diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 8bc3224..3eb4948 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -56,6 +56,7 @@ #include <QtCore/qbasictimer.h> #include <QtCore/qdatetime.h> #include <QtCore/qtimer.h> +#include <QtCore/qtimestamp.h> #include <private/qobject_p.h> #ifdef Q_OS_WIN @@ -113,61 +114,7 @@ private: Q_DECLARE_PUBLIC(QAbstractAnimation) }; -class ElapsedTimer -{ -public: - ElapsedTimer() { - invalidate(); - } - - void invalidate() { - m_started = -1; - } - - bool isValid() const { - return m_started >= 0; - } - - void start() { - m_started = getTickCount_sys(); - } - - qint64 elapsed() const { - qint64 current = getTickCount_sys(); - qint64 delta = current - m_started; - if (delta < 0) - delta += getPeriod_sys(); //we wrapped around - return delta; - } - -private: - enum { - MSECS_PER_HOUR = 3600000, - MSECS_PER_MIN = 60000 - }; - - qint64 m_started; - - quint64 getPeriod_sys() const { -#ifdef Q_OS_WIN - return Q_UINT64_C(0x100000000); -#else - // fallback - return 86400 * 1000; -#endif - } - - qint64 getTickCount_sys() const { -#ifdef Q_OS_WIN - return ::GetTickCount(); -#else - // fallback - const QTime t = QTime::currentTime(); - return MSECS_PER_HOUR * t.hour() + MSECS_PER_MIN * t.minute() + 1000 * t.second() + t.msec(); -#endif - } -}; - +typedef QTimestamp ElapsedTimer; class QUnifiedTimer : public QObject { diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 12a992a..6250094 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -88,7 +88,7 @@ QT_END_NAMESPACE #include "qprocess_p.h" #include <qbytearray.h> -#include <qdatetime.h> +#include <qtimestamp.h> #include <qcoreapplication.h> #include <qsocketnotifier.h> #include <qtimer.h> @@ -1639,7 +1639,7 @@ bool QProcess::waitForBytesWritten(int msecs) if (d->processState == QProcess::NotRunning) return false; if (d->processState == QProcess::Starting) { - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); bool started = waitForStarted(msecs); if (!started) @@ -1676,7 +1676,7 @@ bool QProcess::waitForFinished(int msecs) if (d->processState == QProcess::NotRunning) return false; if (d->processState == QProcess::Starting) { - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); bool started = waitForStarted(msecs); if (!started) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 5119ec0..511154a 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -92,7 +92,6 @@ QT_END_NAMESPACE #include <private/qcoreapplication_p.h> #include <private/qthread_p.h> -#include <qdatetime.h> #include <qfile.h> #include <qfileinfo.h> #include <qlist.h> @@ -101,6 +100,7 @@ QT_END_NAMESPACE #include <qsemaphore.h> #include <qsocketnotifier.h> #include <qthread.h> +#include <qtimestamp.h> #include <errno.h> #include <stdlib.h> @@ -933,7 +933,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs) qDebug("QProcessPrivate::waitForReadyRead(%d)", msecs); #endif - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); forever { @@ -1005,7 +1005,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) qDebug("QProcessPrivate::waitForBytesWritten(%d)", msecs); #endif - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); while (!writeBuffer.isEmpty()) { @@ -1072,7 +1072,7 @@ bool QProcessPrivate::waitForFinished(int msecs) qDebug("QProcessPrivate::waitForFinished(%d)", msecs); #endif - QTime stopWatch; + QTimestamp stopWatch; stopWatch.start(); forever { diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 2da5a7d..3d6364b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -47,7 +47,6 @@ #include "qeventloop.h" #include "qcorecmdlineargs_p.h" #include <qdatastream.h> -#include <qdatetime.h> #include <qdebug.h> #include <qdir.h> #include <qfile.h> @@ -59,6 +58,7 @@ #include <qthreadpool.h> #include <qthreadstorage.h> #include <private/qthread_p.h> +#include <qtimestamp.h> #include <qlibraryinfo.h> #include <qvarlengtharray.h> #include <private/qfactoryloader_p.h> @@ -917,7 +917,7 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int m QThreadData *data = QThreadData::current(); if (!data->eventDispatcher) return; - QTime start; + QTimestamp start; start.start(); if (flags & QEventLoop::DeferredDeletion) QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index 877a77a..57977bc 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -42,9 +42,9 @@ #include "qtimeline.h" #include <private/qobject_p.h> -#include <QtCore/qdatetime.h> #include <QtCore/qcoreevent.h> #include <QtCore/qmath.h> +#include <QtCore/qtimestamp.h> QT_BEGIN_NAMESPACE @@ -70,7 +70,7 @@ public: int currentTime; int timerId; - QTime timer; + QTimestamp timer; QTimeLine::Direction direction; QEasingCurve easingCurve; |