From ba90d5cc8b1d65d28edf127b3ef3b589bdea0f99 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 27 Oct 2011 11:53:05 +0200 Subject: 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 --- .../corelib/thread/qmutex/tst_qmutex.cpp | 40 +++++++++++++++++++++- tests/benchmarks/corelib/thread/thread.pro | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) 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 -#if defined(Q_OS_UNIX) +#ifdef Q_OS_SYMBIAN +# include +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 # include 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 -- cgit v1.2.3