summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qelapsedtimer_mac.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2010-09-30 15:29:40 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2010-12-20 14:23:14 (GMT)
commite679392978c21266ec0bf6f960ab8c5f0621e18b (patch)
tree292f2e214acb4cb9b8f3e89a102d65cb7d9260a9 /src/corelib/tools/qelapsedtimer_mac.cpp
parentdaba2c507ad42c66dafa6a29cffa94e9641e0c58 (diff)
downloadQt-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_mac.cpp')
-rw-r--r--src/corelib/tools/qelapsedtimer_mac.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/tools/qelapsedtimer_mac.cpp b/src/corelib/tools/qelapsedtimer_mac.cpp
index 8fceb49..e51f8b3 100644
--- a/src/corelib/tools/qelapsedtimer_mac.cpp
+++ b/src/corelib/tools/qelapsedtimer_mac.cpp
@@ -97,6 +97,12 @@ qint64 QElapsedTimer::restart()
return absoluteToMSecs(t1 - old);
}
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ uint64_t cpu_time = mach_absolute_time();
+ return absoluteToNSecs(cpu_time - t1);
+}
+
qint64 QElapsedTimer::elapsed() const
{
uint64_t cpu_time = mach_absolute_time();