summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib/thread
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2011-10-27 11:53:05 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-27 16:32:09 +0200
commitba90d5cc8b1d65d28edf127b3ef3b589bdea0f99 (patch)
tree1b3c07ffee7f57cabc55aa36d7bc6971c222c170 /tests/benchmarks/corelib/thread
parent916460929d1de315262d4a9ee91280ecaf3f58f1 (diff)
Update QMutex benchmark to match the one in 4.8
Pull in recent changes in the 4.8 branch for the QMutex benchmark. Change-Id: Ie1e9bff33cecafb36d3d12207100f09f99597f8e Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/benchmarks/corelib/thread')
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp40
-rw-r--r--tests/benchmarks/corelib/thread/thread.pro1
2 files changed, 40 insertions, 1 deletions
diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
index 54708f8639..2cb6221cee 100644
--- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
@@ -44,7 +44,26 @@
#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;
diff --git a/tests/benchmarks/corelib/thread/thread.pro b/tests/benchmarks/corelib/thread/thread.pro
index 26570bacfe..2affee5287 100644
--- a/tests/benchmarks/corelib/thread/thread.pro
+++ b/tests/benchmarks/corelib/thread/thread.pro
@@ -1,3 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
+ qmutex \
qthreadstorage