summaryrefslogtreecommitdiff
path: root/src/corelib/tools/qelapsedtimer_symbian.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2010-09-30 17:29:40 +0200
committerBradley T. Hughes <bradley.hughes@nokia.com>2010-12-20 15:23:14 +0100
commite679392978c21266ec0bf6f960ab8c5f0621e18b (patch)
tree292f2e214acb4cb9b8f3e89a102d65cb7d9260a9 /src/corelib/tools/qelapsedtimer_symbian.cpp
parentdaba2c507ad42c66dafa6a29cffa94e9641e0c58 (diff)
downloadqt4-tools-e679392978c21266ec0bf6f960ab8c5f0621e18b.tar.gz
Add QElapsedTimer::nsecsElapsed() const
Allow sub-millisecond resolution on systems where it is possible. On UNIX, with monotonic clock support we get full nanosecond resolution, microsecond otherwise. On Windows we convert the performance counters to nanoseconds if availble, otherwise we only have millisecond resolution. On Mac, the mach time is converted to nanoseconds. On Symbian, we have microsecond resolution. Reviewed-by: joao
Diffstat (limited to 'src/corelib/tools/qelapsedtimer_symbian.cpp')
-rw-r--r--src/corelib/tools/qelapsedtimer_symbian.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/corelib/tools/qelapsedtimer_symbian.cpp b/src/corelib/tools/qelapsedtimer_symbian.cpp
index 038b1029b7..7cd5f1e1b1 100644
--- a/src/corelib/tools/qelapsedtimer_symbian.cpp
+++ b/src/corelib/tools/qelapsedtimer_symbian.cpp
@@ -64,11 +64,6 @@ static quint64 getMicrosecondFromTick()
return nanokernel_tick_period * (val | (quint64(highdword) << 32));
}
-static quint64 getMillisecondFromTick()
-{
- return getMicrosecondFromTick() / 1000;
-}
-
timeval qt_gettime()
{
timeval tv;
@@ -91,36 +86,41 @@ bool QElapsedTimer::isMonotonic()
void QElapsedTimer::start()
{
- t1 = getMillisecondFromTick();
+ t1 = getMicrosecondFromTick();
t2 = 0;
}
qint64 QElapsedTimer::restart()
{
qint64 oldt1 = t1;
- t1 = getMillisecondFromTick();
+ t1 = getMicrosecondFromTick();
t2 = 0;
return t1 - oldt1;
}
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ return (getMicrosecondFromTick() - t1) * 1000;
+}
+
qint64 QElapsedTimer::elapsed() const
{
- return getMillisecondFromTick() - t1;
+ return (getMicrosecondFromTick() - t1) / 1000;
}
qint64 QElapsedTimer::msecsSinceReference() const
{
- return t1;
+ return t1 / 1000;
}
qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
{
- return other.t1 - t1;
+ return (other.t1 - t1) / 1000;
}
qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const
{
- return msecsTo(other) / 1000;
+ return msecsTo(other) / 1000000;
}
bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2)