diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-09-30 15:29:40 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-12-20 14:23:14 (GMT) |
commit | e679392978c21266ec0bf6f960ab8c5f0621e18b (patch) | |
tree | 292f2e214acb4cb9b8f3e89a102d65cb7d9260a9 /src/corelib/tools/qelapsedtimer_generic.cpp | |
parent | daba2c507ad42c66dafa6a29cffa94e9641e0c58 (diff) | |
download | Qt-e679392978c21266ec0bf6f960ab8c5f0621e18b.zip Qt-e679392978c21266ec0bf6f960ab8c5f0621e18b.tar.gz Qt-e679392978c21266ec0bf6f960ab8c5f0621e18b.tar.bz2 |
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_generic.cpp')
-rw-r--r-- | src/corelib/tools/qelapsedtimer_generic.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp index 85986e6..740f496 100644 --- a/src/corelib/tools/qelapsedtimer_generic.cpp +++ b/src/corelib/tools/qelapsedtimer_generic.cpp @@ -103,6 +103,22 @@ qint64 QElapsedTimer::restart() return t1 - old; } +/*! \since 4.8 + + Returns the number of nanoseconds since this QElapsedTimer was last + started. Calling this function in a QElapsedTimer that was invalidated + will result in undefined results. + + On platforms that do not provide nanosecond resolution, the value returned + will be the best estimate available. + + \sa start(), restart(), hasExpired(), invalidate() +*/ +qint64 QElapsedTimer::nsecsElapsed() const +{ + return elapsed() * 1000000; +} + /*! Returns the number of milliseconds since this QElapsedTimer was last started. Calling this function in a QElapsedTimer that was invalidated |