summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp10
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp6
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp66
-rw-r--r--tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp96
-rw-r--r--tests/benchmarks/gui/painting/lancebench/CMakeLists.txt10
-rw-r--r--tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp2
8 files changed, 167 insertions, 27 deletions
diff --git a/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
index 4ed1246a6c..b22c15b07f 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
+++ b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
@@ -30,7 +30,7 @@
#include <QDirIterator>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#else
# include <sys/stat.h>
# include <sys/types.h>
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
index 10b1b90ce2..fe68d9164d 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -85,7 +85,7 @@
#include <qplatformdefs.h>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#else
# include <sys/stat.h>
# include <sys/types.h>
diff --git a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
index e7026c70f9..015c49ed04 100644
--- a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
+++ b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
@@ -38,7 +38,7 @@
#include <stdio.h>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#endif
#if defined(Q_OS_QNX) && defined(open)
@@ -263,7 +263,7 @@ void tst_qfile::readBigFile()
#ifdef QT_BUILD_INTERNAL
case QFSFileEngineBenchmark: {
QFSFileEngine fse(tempDir.filename);
- fse.open(QIODevice::ReadOnly|textMode|bufferedMode);
+ fse.open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt);
QBENCHMARK {
//qWarning() << fse.supportsExtension(QAbstractFileEngine::AtEndExtension);
while (fse.read(buffer, blockSize)) {}
@@ -349,7 +349,7 @@ void tst_qfile::seek()
#ifdef QT_BUILD_INTERNAL
case QFSFileEngineBenchmark: {
QFSFileEngine fse(tempDir.filename);
- fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt);
QBENCHMARK {
i=(i+1)%sp_size;
fse.seek(seekpos[i]);
@@ -426,7 +426,7 @@ void tst_qfile::open()
case QFSFileEngineBenchmark: {
QBENCHMARK {
QFSFileEngine fse(tempDir.filename);
- fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt);
fse.close();
}
}
@@ -550,7 +550,7 @@ void tst_qfile::readSmallFiles()
QList<QFSFileEngine*> fileList;
for (const QString &file : files) {
QFSFileEngine *fse = new QFSFileEngine(tempDir.filePath(file));
- fse->open(QIODevice::ReadOnly|textMode|bufferedMode);
+ fse->open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt);
fileList.append(fse);
}
diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp
index 987612b7b2..2042aa4885 100644
--- a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp
+++ b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp
@@ -76,8 +76,10 @@ void NativeMutexUnlock(NativeMutexType *mutex)
}
#endif
#elif defined(Q_OS_WIN)
-# define _WIN32_WINNT 0x0400
-# include <windows.h>
+# if !defined(_WIN32_WINNT)
+# define _WIN32_WINNT 0x0A00
+# endif
+# include <qt_windows.h>
typedef CRITICAL_SECTION NativeMutexType;
void NativeMutexInitialize(NativeMutexType *mutex)
{
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp
index be12877df1..824f85ec6a 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp
@@ -44,6 +44,49 @@ struct LockerWrapper : T
}
};
+struct QRecursiveReadWriteLock : QReadWriteLock
+{
+ QRecursiveReadWriteLock() : QReadWriteLock(Recursive) {}
+};
+
+template <typename T, size_t N>
+ // requires N = 2^M for some Integral M >= 0
+struct Recursive
+{
+ Recursive<T, N/2> r1, r2;
+
+ template <typename...Args>
+ Q_ALWAYS_INLINE
+ explicit Recursive(Args &&...args)
+ : r1(args...),
+ r2(args...)
+ {}
+};
+
+template <typename T>
+struct Recursive<T, 1>
+{
+ T t;
+ template <typename...Args>
+ Q_ALWAYS_INLINE
+ explicit Recursive(Args &&...args)
+ : t(args...) {}
+};
+
+template <typename T>
+struct Recursive<T, 0>
+{
+ template <typename...Args>
+ Q_ALWAYS_INLINE
+ explicit Recursive(Args &&...) {}
+};
+
+template <size_t N>
+using QRecursiveReadLocker = Recursive<QReadLocker, N>;
+
+template <size_t N>
+using QRecursiveWriteLocker = Recursive<QWriteLocker, N>;
+
int threadCount;
class tst_QReadWriteLock : public QObject
@@ -105,6 +148,15 @@ void tst_QReadWriteLock::uncontended_data()
<< FunctionPtrHolder(testUncontended<QReadWriteLock, QReadLocker>);
QTest::newRow("QReadWriteLock, write")
<< FunctionPtrHolder(testUncontended<QReadWriteLock, QWriteLocker>);
+#define ROW(n) \
+ QTest::addRow("QReadWriteLock, %s, recursive: %d", "read", n) \
+ << FunctionPtrHolder(testUncontended<QRecursiveReadWriteLock, QRecursiveReadLocker<n>>); \
+ QTest::addRow("QReadWriteLock, %s, recursive: %d", "write", n) \
+ << FunctionPtrHolder(testUncontended<QRecursiveReadWriteLock, QRecursiveWriteLocker<n>>)
+ ROW(1);
+ ROW(2);
+ ROW(32);
+#undef ROW
QTest::newRow("std::mutex") << FunctionPtrHolder(
testUncontended<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
#ifdef __cpp_lib_shared_mutex
@@ -172,6 +224,13 @@ void tst_QReadWriteLock::readOnly_data()
QTest::newRow("nothing") << FunctionPtrHolder(testReadOnly<int, FakeLock>);
QTest::newRow("QMutex") << FunctionPtrHolder(testReadOnly<QMutex, QMutexLocker<QMutex>>);
QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testReadOnly<QReadWriteLock, QReadLocker>);
+#define ROW(n) \
+ QTest::addRow("QReadWriteLock, recursive: %d", n) \
+ << FunctionPtrHolder(testReadOnly<QRecursiveReadWriteLock, QRecursiveReadLocker<n>>)
+ ROW(1);
+ ROW(2);
+ ROW(32);
+#undef ROW
QTest::newRow("std::mutex") << FunctionPtrHolder(
testReadOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
#ifdef __cpp_lib_shared_mutex
@@ -233,6 +292,13 @@ void tst_QReadWriteLock::writeOnly_data()
// QTest::newRow("nothing") << FunctionPtrHolder(testWriteOnly<int, FakeLock>);
QTest::newRow("QMutex") << FunctionPtrHolder(testWriteOnly<QMutex, QMutexLocker<QMutex>>);
QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testWriteOnly<QReadWriteLock, QWriteLocker>);
+#define ROW(n) \
+ QTest::addRow("QReadWriteLock, recursive: %d", n) \
+ << FunctionPtrHolder(testWriteOnly<QRecursiveReadWriteLock, QRecursiveWriteLocker<n>>)
+ ROW(1);
+ ROW(2);
+ ROW(32);
+#undef ROW
QTest::newRow("std::mutex") << FunctionPtrHolder(
testWriteOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
#ifdef __cpp_lib_shared_mutex
diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp b/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp
index 19d3964c7a..3612b8784b 100644
--- a/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp
+++ b/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp
@@ -30,7 +30,12 @@
#include <QTest>
#include <math.h>
+#include <condition_variable>
+#include <mutex>
+#include <limits.h>
+
+using namespace std::chrono_literals;
class tst_QWaitCondition : public QObject
{
@@ -42,24 +47,67 @@ public:
}
private slots:
+ void oscillate_QWaitCondition_QMutex_data() { oscillate_mutex_data(); }
+ void oscillate_QWaitCondition_QMutex();
+ void oscillate_QWaitCondition_QReadWriteLock_data() { oscillate_mutex_data(); }
+ void oscillate_QWaitCondition_QReadWriteLock();
+ void oscillate_std_condition_variable_std_mutex_data() { oscillate_mutex_data(); }
+ void oscillate_std_condition_variable_std_mutex();
+ void oscillate_std_condition_variable_any_QMutex_data() { oscillate_mutex_data(); }
+ void oscillate_std_condition_variable_any_QMutex();
+ void oscillate_std_condition_variable_any_QReadWriteLock_data() { oscillate_mutex_data(); }
+ void oscillate_std_condition_variable_any_QReadWriteLock();
+
+private:
void oscillate_mutex_data();
- void oscillate_mutex();
- void oscillate_writelock_data();
- void oscillate_writelock();
};
int turn;
const int threadCount = 10;
QWaitCondition cond;
+std::condition_variable cv;
+std::condition_variable_any cva;
-template <class Mutex, class Locker>
+template <typename Cond>
+Cond *get();
+
+template <> std::condition_variable *get() { return &cv; }
+template <> std::condition_variable_any *get() { return &cva; }
+
+template <class Cond, class Mutex, class Locker>
class OscillateThread : public QThread
{
public:
Mutex *mutex;
int m_threadid;
- int timeout;
+ unsigned long timeout;
+
+ void run() override
+ {
+ for (int count = 0; count < 5000; ++count) {
+ Locker lock(*mutex);
+ while (m_threadid != turn) {
+ if (timeout == ULONG_MAX)
+ get<Cond>()->wait(lock);
+ else if (timeout == 0) // Windows doesn't unlock the mutex with a zero timeout
+ get<Cond>()->wait_for(lock, 1ns);
+ else
+ get<Cond>()->wait_for(lock, timeout * 1ms);
+ }
+ turn = (turn+1) % threadCount;
+ get<Cond>()->notify_all();
+ }
+ }
+};
+
+template <class Mutex, class Locker>
+class OscillateThread<QWaitCondition, Mutex, Locker> : public QThread
+{
+public:
+ Mutex *mutex;
+ int m_threadid;
+ unsigned long timeout;
void run() override
{
@@ -75,10 +123,10 @@ public:
}
};
-template <class Mutex, class Locker>
+template <class Cond, class Mutex, class Locker>
void oscillate(unsigned long timeout) {
- OscillateThread<Mutex, Locker> thrd[threadCount];
+ OscillateThread<Cond, Mutex, Locker> thrd[threadCount];
Mutex m;
for (int i = 0; i < threadCount; ++i) {
thrd[i].mutex = &m;
@@ -107,21 +155,43 @@ void tst_QWaitCondition::oscillate_mutex_data()
QTest::newRow("forever") << ULONG_MAX;
}
-void tst_QWaitCondition::oscillate_mutex()
+void tst_QWaitCondition::oscillate_QWaitCondition_QMutex()
{
QFETCH(unsigned long, timeout);
- oscillate<QMutex, QMutexLocker<QMutex>>(timeout);
+ oscillate<QWaitCondition, QMutex, QMutexLocker<QMutex>>(timeout);
}
-void tst_QWaitCondition::oscillate_writelock_data()
+void tst_QWaitCondition::oscillate_QWaitCondition_QReadWriteLock()
{
- oscillate_mutex_data();
+ QFETCH(unsigned long, timeout);
+ oscillate<QWaitCondition, QReadWriteLock, QWriteLocker>(timeout);
}
-void tst_QWaitCondition::oscillate_writelock()
+void tst_QWaitCondition::oscillate_std_condition_variable_std_mutex()
{
QFETCH(unsigned long, timeout);
- oscillate<QReadWriteLock, QWriteLocker>(timeout);
+ oscillate<std::condition_variable, std::mutex, std::unique_lock<std::mutex>>(timeout);
+}
+
+
+void tst_QWaitCondition::oscillate_std_condition_variable_any_QMutex()
+{
+ QFETCH(unsigned long, timeout);
+ oscillate<std::condition_variable_any, QMutex, std::unique_lock<QMutex>>(timeout);
+}
+
+
+void tst_QWaitCondition::oscillate_std_condition_variable_any_QReadWriteLock()
+{
+ QFETCH(unsigned long, timeout);
+
+ struct WriteLocker : QWriteLocker {
+ // adapt to BasicLockable
+ explicit WriteLocker(QReadWriteLock &m) : QWriteLocker{&m} {}
+ void lock() { relock(); }
+ };
+
+ oscillate<std::condition_variable_any, QReadWriteLock, WriteLocker>(timeout);
}
QTEST_MAIN(tst_QWaitCondition)
diff --git a/tests/benchmarks/gui/painting/lancebench/CMakeLists.txt b/tests/benchmarks/gui/painting/lancebench/CMakeLists.txt
index e278f0ddc0..f417bcc61a 100644
--- a/tests/benchmarks/gui/painting/lancebench/CMakeLists.txt
+++ b/tests/benchmarks/gui/painting/lancebench/CMakeLists.txt
@@ -6,8 +6,10 @@
qt_internal_add_benchmark(tst_bench_lancebench
SOURCES
- ../../../../auto/other/lancelot/paintcommands.cpp ../../../../auto/other/lancelot/paintcommands.h
+ ../../../../baseline/painting/paintcommands.cpp ../../../../baseline/painting/paintcommands.h
tst_lancebench.cpp
+ INCLUDE_DIRECTORIES
+ ../../../../baseline/painting
PUBLIC_LIBRARIES
Qt::Gui
Qt::GuiPrivate
@@ -47,13 +49,13 @@ set(images_resource_files
"images/zebra.png"
)
-list(TRANSFORM images_resource_files PREPEND "../../../../auto/other/lancelot/")
+list(TRANSFORM images_resource_files PREPEND "../../../../baseline/painting/")
qt_internal_add_resource(tst_bench_lancebench "images"
PREFIX
"/"
BASE
- "../../../../auto/other/lancelot"
+ "../../../../baseline/painting"
FILES
${images_resource_files}
)
@@ -61,7 +63,7 @@ qt_internal_add_resource(tst_bench_lancebench "images"
#### Keys ignored in scope 1:.:.:lancebench.pro:<TRUE>:
# TEMPLATE = "app"
-# TESTDATA = "../../../../auto/other/lancelot/scripts/*"
+# TESTDATA = "../../../../baseline/painting/scripts/*"
## Scopes:
#####################################################################
diff --git a/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp b/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp
index 418f0623b3..b6f7d693b9 100644
--- a/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp
+++ b/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "../../../../auto/other/lancelot/paintcommands.h"
+#include "paintcommands.h"
#include <qtest.h>
#include <QDir>