diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-06-03 09:50:04 +1000 |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2011-06-03 09:50:04 +1000 |
commit | cd6ebb4912a5d96c788ea0c838d8a1a06ff4029e (patch) | |
tree | 315b6191e961c1bb4cab972b62455740c574b15d /src/declarative/qml | |
parent | f97e25abe073bede66cc5683ae45baea3a528d44 (diff) |
Replace QPerformanceTimer with QElapsedTimer.
QElapsedTimer has added a nsecsElapsed() function, so QPerformanceTimer
is no longer needed.
Reviewed-by: Charles Yin
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qml.pri | 4 | ||||
-rw-r--r-- | src/declarative/qml/qperformancetimer.cpp | 226 | ||||
-rw-r--r-- | src/declarative/qml/qperformancetimer_p.h | 79 |
3 files changed, 1 insertions, 308 deletions
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 62c1f97d60..78fb06358e 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -54,8 +54,7 @@ SOURCES += \ $$PWD/qdeclarativedirparser.cpp \ $$PWD/qdeclarativeextensionplugin.cpp \ $$PWD/qdeclarativeimport.cpp \ - $$PWD/qdeclarativelist.cpp \ - $$PWD/qperformancetimer.cpp \ + $$PWD/qdeclarativelist.cpp \ $$PWD/qintrusivelist.cpp \ HEADERS += \ @@ -129,7 +128,6 @@ HEADERS += \ $$PWD/qdeclarativeextensioninterface.h \ $$PWD/qdeclarativeimport_p.h \ $$PWD/qdeclarativeextensionplugin.h \ - $$PWD/qperformancetimer_p.h \ $$PWD/qintrusivelist_p.h \ QT += sql diff --git a/src/declarative/qml/qperformancetimer.cpp b/src/declarative/qml/qperformancetimer.cpp deleted file mode 100644 index 9fc0d35696..0000000000 --- a/src/declarative/qml/qperformancetimer.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qperformancetimer_p.h" - -#if defined(Q_OS_MAC) -#include <sys/time.h> -#include <unistd.h> -#include <mach/mach_time.h> -#elif defined(Q_OS_UNIX) -#include <sys/time.h> -#include <time.h> -#include <unistd.h> -#elif defined(Q_OS_SYMBIAN) -#include <e32std.h> -#include <sys/time.h> -#include <hal.h> -#elif defined(Q_OS_WIN) -#include <windows.h> -#endif - -// mac/unix code heavily copied from QElapsedTimer - -QT_BEGIN_NAMESPACE - -////////////////////////////// Mac ////////////////////////////// -#if defined(Q_OS_MAC) - -static mach_timebase_info_data_t info = {0,0}; -static qint64 absoluteToNSecs(qint64 cpuTime) -{ - if (info.denom == 0) - mach_timebase_info(&info); - qint64 nsecs = cpuTime * info.numer / info.denom; - return nsecs; -} - -void QPerformanceTimer::start() -{ - t1 = mach_absolute_time(); -} - -qint64 QPerformanceTimer::elapsed() const -{ - uint64_t cpu_time = mach_absolute_time(); - return absoluteToNSecs(cpu_time - t1); -} - -////////////////////////////// Unix ////////////////////////////// -#elif defined(Q_OS_UNIX) - -#if defined(QT_NO_CLOCK_MONOTONIC) || defined(QT_BOOTSTRAPPED) -// turn off the monotonic clock -# ifdef _POSIX_MONOTONIC_CLOCK -# undef _POSIX_MONOTONIC_CLOCK -# endif -# define _POSIX_MONOTONIC_CLOCK -1 -#endif - -#if (_POSIX_MONOTONIC_CLOCK-0 != 0) -static const bool monotonicClockChecked = true; -static const bool monotonicClockAvailable = _POSIX_MONOTONIC_CLOCK > 0; -#else -static int monotonicClockChecked = false; -static int monotonicClockAvailable = false; -#endif - -#ifdef Q_CC_GNU -# define is_likely(x) __builtin_expect((x), 1) -#else -# define is_likely(x) (x) -#endif -#define load_acquire(x) ((volatile const int&)(x)) -#define store_release(x,v) ((volatile int&)(x) = (v)) - -static void unixCheckClockType() -{ -#if (_POSIX_MONOTONIC_CLOCK-0 == 0) - if (is_likely(load_acquire(monotonicClockChecked))) - return; - -# if defined(_SC_MONOTONIC_CLOCK) - // detect if the system support monotonic timers - long x = sysconf(_SC_MONOTONIC_CLOCK); - store_release(monotonicClockAvailable, x >= 200112L); -# endif - - store_release(monotonicClockChecked, true); -#endif -} - -static inline void do_gettime(qint64 *sec, qint64 *frac) -{ -#if (_POSIX_MONOTONIC_CLOCK-0 >= 0) - unixCheckClockType(); - if (is_likely(monotonicClockAvailable)) { - timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - *sec = ts.tv_sec; - *frac = ts.tv_nsec; - return; - } -#endif - *sec = 0; - *frac = 0; -} - -void QPerformanceTimer::start() -{ - do_gettime(&t1, &t2); -} - -qint64 QPerformanceTimer::elapsed() const -{ - qint64 sec, frac; - do_gettime(&sec, &frac); - sec = sec - t1; - frac = frac - t2; - - return sec * Q_INT64_C(1000000000) + frac; -} - -////////////////////////////// Symbian ////////////////////////////// -#elif defined(Q_OS_SYMBIAN) - -static qint64 getTimeFromTick(quint64 elapsed) -{ - static TInt freq; - if (!freq) - HAL::Get(HALData::EFastCounterFrequency, freq); - - // ### not sure on units - return elapsed / freq; -} - -void QPerformanceTimer::start() -{ - t1 = User::FastCounter(); -} - -qint64 QPerformanceTimer::elapsed() const -{ - return getTimeFromTick(User::FastCounter() - t1); -} - -////////////////////////////// Windows ////////////////////////////// -#elif defined(Q_OS_WIN) - -static qint64 getTimeFromTick(quint64 elapsed) -{ - static LARGE_INTEGER freq; - if (!freq.QuadPart) - QueryPerformanceFrequency(&freq); - return 1000000000 * elapsed / freq.QuadPart; -} - -void QPerformanceTimer::start() -{ - LARGE_INTEGER li; - QueryPerformanceCounter(&li); - t1 = li.QuadPart; -} - -qint64 QPerformanceTimer::elapsed() const -{ - LARGE_INTEGER li; - QueryPerformanceCounter(&li); - return getTimeFromTick(li.QuadPart - t1); -} - -////////////////////////////// Default ////////////////////////////// -#else - -// default implementation (no hi-perf timer) does nothing -void QPerformanceTimer::start() -{ -} - -qint64 QPerformanceTimer::elapsed() const -{ - return 0; -} - -#endif - -QT_END_NAMESPACE - - diff --git a/src/declarative/qml/qperformancetimer_p.h b/src/declarative/qml/qperformancetimer_p.h deleted file mode 100644 index 48b286eac8..0000000000 --- a/src/declarative/qml/qperformancetimer_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPERFORMANCETIMER_P_H -#define QPERFORMANCETIMER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of moc. This header file may change from version to version without notice, -// or even be removed. -// -// We mean it. -// - -#include <QtCore/qglobal.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_AUTOTEST_EXPORT QPerformanceTimer -{ -public: - void start(); - qint64 elapsed() const; - -private: - qint64 t1; - qint64 t2; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPERFORMANCETIMER_P_H |