Update QMutex benchmark to match the one in 4.8
authorBradley T. Hughes <bradley.hughes@nokia.com>
Thu, 27 Oct 2011 09:53:05 +0000 (11:53 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 27 Oct 2011 14:32:09 +0000 (16:32 +0200)
Pull in recent changes in the 4.8 branch for the QMutex benchmark.

Change-Id: Ie1e9bff33cecafb36d3d12207100f09f99597f8e
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
tests/benchmarks/corelib/thread/thread.pro

index 54708f8..2cb6221 100644 (file)
 
 #include <math.h>
 
-#if defined(Q_OS_UNIX)
+#ifdef Q_OS_SYMBIAN
+# include <e32std.h>
+typedef RMutex NativeMutexType;
+void NativeMutexInitialize(NativeMutexType *mutex)
+{
+    mutex->CreateLocal();
+}
+void NativeMutexDestroy(NativeMutexType *mutex)
+{
+    mutex->Close();
+}
+void NativeMutexLock(NativeMutexType *mutex)
+{
+    mutex->Wait();
+}
+void NativeMutexUnlock(NativeMutexType *mutex)
+{
+    mutex->Signal();
+}
+#elif defined(Q_OS_UNIX)
 #  include <pthread.h>
 #  include <errno.h>
 typedef pthread_mutex_t NativeMutexType;
@@ -109,7 +128,9 @@ private slots:
     void noThread_data();
     void noThread();
 
+    void constructionNative();
     void uncontendedNative();
+    void constructionQMutex();
     void uncontendedQMutex();
     void uncontendedQMutexLocker();
 
@@ -175,6 +196,15 @@ void tst_QMutex::noThread()
     QCOMPARE(int(count), N);
 }
 
+void tst_QMutex::constructionNative()
+{
+    QBENCHMARK {
+        NativeMutexType mutex;
+        NativeMutexInitialize(&mutex);
+        NativeMutexDestroy(&mutex);
+    }
+}
+
 void tst_QMutex::uncontendedNative()
 {
     NativeMutexType mutex;
@@ -186,6 +216,14 @@ void tst_QMutex::uncontendedNative()
     NativeMutexDestroy(&mutex);
 }
 
+void tst_QMutex::constructionQMutex()
+{
+    QBENCHMARK {
+        QMutex mutex;
+        Q_UNUSED(mutex);
+    }
+}
+
 void tst_QMutex::uncontendedQMutex()
 {
     QMutex mutex;
index 26570ba..2affee5 100644 (file)
@@ -1,3 +1,4 @@
 TEMPLATE = subdirs
 SUBDIRS = \
+        qmutex \
         qthreadstorage