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>
This commit is contained in:
parent
916460929d
commit
ba90d5cc8b
@ -44,7 +44,26 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#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 <pthread.h>
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
typedef pthread_mutex_t NativeMutexType;
|
typedef pthread_mutex_t NativeMutexType;
|
||||||
@ -109,7 +128,9 @@ private slots:
|
|||||||
void noThread_data();
|
void noThread_data();
|
||||||
void noThread();
|
void noThread();
|
||||||
|
|
||||||
|
void constructionNative();
|
||||||
void uncontendedNative();
|
void uncontendedNative();
|
||||||
|
void constructionQMutex();
|
||||||
void uncontendedQMutex();
|
void uncontendedQMutex();
|
||||||
void uncontendedQMutexLocker();
|
void uncontendedQMutexLocker();
|
||||||
|
|
||||||
@ -175,6 +196,15 @@ void tst_QMutex::noThread()
|
|||||||
QCOMPARE(int(count), N);
|
QCOMPARE(int(count), N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMutex::constructionNative()
|
||||||
|
{
|
||||||
|
QBENCHMARK {
|
||||||
|
NativeMutexType mutex;
|
||||||
|
NativeMutexInitialize(&mutex);
|
||||||
|
NativeMutexDestroy(&mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QMutex::uncontendedNative()
|
void tst_QMutex::uncontendedNative()
|
||||||
{
|
{
|
||||||
NativeMutexType mutex;
|
NativeMutexType mutex;
|
||||||
@ -186,6 +216,14 @@ void tst_QMutex::uncontendedNative()
|
|||||||
NativeMutexDestroy(&mutex);
|
NativeMutexDestroy(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMutex::constructionQMutex()
|
||||||
|
{
|
||||||
|
QBENCHMARK {
|
||||||
|
QMutex mutex;
|
||||||
|
Q_UNUSED(mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QMutex::uncontendedQMutex()
|
void tst_QMutex::uncontendedQMutex()
|
||||||
{
|
{
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
|
qmutex \
|
||||||
qthreadstorage
|
qthreadstorage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user