summaryrefslogtreecommitdiff
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2011-10-21 09:59:54 +0200
committerBradley T. Hughes <bradley.hughes@nokia.com>2011-10-21 10:57:42 +0200
commit0375fff2b077ddd20a97c1b1c8d34f22553abe0c (patch)
treee865f2a984fc29d3a428a0121a893a2c8f00dd84 /tests/benchmarks
parent2df43004a5c093879371574cfe9ea3f68fefa69c (diff)
downloadqt4-tools-0375fff2b077ddd20a97c1b1c8d34f22553abe0c.tar.gz
Fix performance regression on Mac OS X when creating/destroying QMutex
This reverts commit cf17b743d2fe84ab259b7232ab07b58a1872e18e, which changed QMutex to use a Mach semaphore_t on Mac OS X. We now use pthread_mutex_t on Mac OS X as well. Contention performance is mostly unchanged, but the new constructionQMutex() benchmark added in this commit shows that creating/destroying a semaphore_t is about 20 times slower than pthread_mutex_t. Reviewed-by: Olivier Goffart Reviewed-by: João Abecasis
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
index 05a15750c1..eca38b6b5f 100644
--- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
@@ -128,7 +128,9 @@ private slots:
void noThread_data();
void noThread();
+ void constructionNative();
void uncontendedNative();
+ void constructionQMutex();
void uncontendedQMutex();
void uncontendedQMutexLocker();
@@ -205,6 +207,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;
@@ -216,6 +227,14 @@ void tst_QMutex::uncontendedNative()
NativeMutexDestroy(&mutex);
}
+void tst_QMutex::constructionQMutex()
+{
+ QBENCHMARK {
+ QMutex mutex;
+ Q_UNUSED(mutex);
+ }
+}
+
void tst_QMutex::uncontendedQMutex()
{
QMutex mutex;