summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib')
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp5
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro7
-rw-r--r--tests/benchmarks/corelib/io/qfile/main.cpp7
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/main.cpp4
-rw-r--r--tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp7
-rw-r--r--tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp32
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro6
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp183
-rw-r--r--tests/benchmarks/corelib/thread/thread.pro1
-rw-r--r--tests/benchmarks/corelib/tools/containers-sequential/main.cpp7
-rw-r--r--tests/benchmarks/corelib/tools/qcryptographichash/main.cpp9
11 files changed, 229 insertions, 39 deletions
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index a9fd7fd5ec..cd5a83e547 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -59,10 +59,6 @@ private slots:
void tst_qdiriterator::data()
{
-#if defined(Q_OS_WINCE)
- QByteArray qtdir = qPrintable(QCoreApplication::applicationDirPath());
- qtdir += "/depot";
-#else
#if defined(Q_OS_WIN)
const char *qtdir = "C:\\depot\\qt\\main";
#else
@@ -72,7 +68,6 @@ void tst_qdiriterator::data()
fprintf(stderr, "QTDIR not set\n");
exit(1);
}
-#endif
QTest::addColumn<QByteArray>("dirpath");
QByteArray ba = QByteArray(qtdir) + "/src/corelib";
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
index 3cfb0b44de..061b22a5d1 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
+++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
@@ -6,10 +6,3 @@ CONFIG += release
SOURCES += main.cpp qfilesystemiterator.cpp
HEADERS += qfilesystemiterator.h
-
-wince* {
- corelibdir.files = $$QT_SOURCE_TREE/src/corelib
- corelibdir.path = ./depot/src
- DEPLOYMENT += corelibdir
-}
-
diff --git a/tests/benchmarks/corelib/io/qfile/main.cpp b/tests/benchmarks/corelib/io/qfile/main.cpp
index 175dc74074..1966b30773 100644
--- a/tests/benchmarks/corelib/io/qfile/main.cpp
+++ b/tests/benchmarks/corelib/io/qfile/main.cpp
@@ -591,12 +591,7 @@ void tst_qfile::createSmallFiles()
dir.cd("tst");
tmpDirName = dir.absolutePath();
-#if defined(Q_OS_WINCE)
- for (int i = 0; i < 100; ++i)
-#else
- for (int i = 0; i < 1000; ++i)
-#endif
- {
+ for (int i = 0; i < 1000; ++i) {
QFile f(tmpDirName + QLatin1Char('/') + QString::number(i));
f.open(QIODevice::WriteOnly);
f.seek(511);
diff --git a/tests/benchmarks/corelib/io/qfileinfo/main.cpp b/tests/benchmarks/corelib/io/qfileinfo/main.cpp
index 24a32a7c72..5180e7c29e 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/main.cpp
+++ b/tests/benchmarks/corelib/io/qfileinfo/main.cpp
@@ -41,7 +41,7 @@ class qfileinfo : public QObject
private slots:
void existsTemporary();
void existsStatic();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void symLinkTargetPerformanceLNK();
void symLinkTargetPerformanceMounpoint();
#endif
@@ -71,7 +71,7 @@ void qfileinfo::existsStatic()
QBENCHMARK { QFileInfo::exists(appPath); }
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void qfileinfo::symLinkTargetPerformanceLNK()
{
QVERIFY(QFile::link("file","link.lnk"));
diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
index d8792ed7ef..782cad94a1 100644
--- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
+++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
@@ -33,7 +33,7 @@ class tst_QProcess : public QObject
{
Q_OBJECT
-#if !defined(QT_NO_PROCESS) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_PROCESS)
private slots:
void echoTest_performance();
@@ -41,8 +41,7 @@ private slots:
#endif // QT_NO_PROCESS
};
-#if !defined(QT_NO_PROCESS) && !defined(Q_OS_WINCE)
-// Reading and writing to a process is not supported on Qt/CE
+#if !defined(QT_NO_PROCESS)
void tst_QProcess::echoTest_performance()
{
QProcess process;
@@ -88,7 +87,7 @@ void tst_QProcess::echoTest_performance()
QVERIFY(process.waitForFinished());
}
-#endif // QT_NO_PROCESS && Q_OS_WINCE
+#endif // QT_NO_PROCESS
QTEST_MAIN(tst_QProcess)
#include "tst_bench_qprocess.moc"
diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp
index 9abb9466df..287afff089 100644
--- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -37,6 +37,15 @@
class tst_qvariant : public QObject
{
Q_OBJECT
+
+public:
+ enum ABenchmarkEnum {
+ FirstEnumValue,
+ SecondEnumValue,
+ ThirdEnumValue
+ };
+ Q_ENUM(ABenchmarkEnum)
+
private slots:
void testBound();
@@ -50,6 +59,7 @@ private slots:
void stringListVariantCreation();
void bigClassVariantCreation();
void smallClassVariantCreation();
+ void enumVariantCreation();
void doubleVariantSetValue();
void floatVariantSetValue();
@@ -58,6 +68,7 @@ private slots:
void stringListVariantSetValue();
void bigClassVariantSetValue();
void smallClassVariantSetValue();
+ void enumVariantSetValue();
void doubleVariantAssignment();
void floatVariantAssignment();
@@ -136,6 +147,16 @@ void variantCreation<SmallClass>(SmallClass val)
}
}
+template <>
+void variantCreation<tst_qvariant::ABenchmarkEnum>(tst_qvariant::ABenchmarkEnum val)
+{
+ QBENCHMARK {
+ for (int i = 0; i < ITERATION_COUNT; ++i) {
+ QVariant::fromValue(val);
+ }
+ }
+}
+
void tst_qvariant::doubleVariantCreation()
{
@@ -179,6 +200,12 @@ void tst_qvariant::smallClassVariantCreation()
variantCreation<SmallClass>(SmallClass());
}
+void tst_qvariant::enumVariantCreation()
+{
+ variantCreation<ABenchmarkEnum>(FirstEnumValue);
+}
+
+
template <typename T>
static void variantSetValue(T d)
{
@@ -225,6 +252,11 @@ void tst_qvariant::smallClassVariantSetValue()
variantSetValue<SmallClass>(SmallClass());
}
+void tst_qvariant::enumVariantSetValue()
+{
+ variantSetValue<ABenchmarkEnum>(FirstEnumValue);
+}
+
template <typename T>
static void variantAssignment(T d)
{
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
new file mode 100644
index 0000000000..86102adecd
--- /dev/null
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_bench_qreadwritelock
+QT = core testlib
+SOURCES += tst_qreadwritelock.cpp
+CONFIG += c++14 # for std::shared_timed_mutex
+
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
new file mode 100644
index 0000000000..bdec6c3a0a
--- /dev/null
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtCore>
+#include <QtTest/QtTest>
+#include <mutex>
+#if QT_HAS_INCLUDE(<shared_mutex>)
+#if __cplusplus > 201103L
+#include <shared_mutex>
+#endif
+#endif
+
+// Wrapers that take pointers instead of reference to have the same interface as Qt
+template <typename T>
+struct LockerWrapper : T
+{
+ LockerWrapper(typename T::mutex_type *mtx)
+ : T(*mtx)
+ {
+ }
+};
+
+int threadCount;
+
+class tst_QReadWriteLock : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QReadWriteLock()
+ {
+ // at least 2 threads, even on single cpu/core machines
+ threadCount = qMax(2, QThread::idealThreadCount());
+ qDebug("thread count: %d", threadCount);
+ }
+
+private slots:
+ void uncontended_data();
+ void uncontended();
+ void readOnly_data();
+ void readOnly();
+ // void readWrite();
+};
+
+struct FunctionPtrHolder
+{
+ FunctionPtrHolder(QFunctionPointer value = nullptr)
+ : value(value)
+ {
+ }
+ QFunctionPointer value;
+};
+Q_DECLARE_METATYPE(FunctionPtrHolder)
+
+struct FakeLock
+{
+ FakeLock(volatile int *i) { *i = 0; }
+};
+
+enum { Iterations = 1000000 };
+
+template <typename Mutex, typename Locker>
+void testUncontended()
+{
+ Mutex lock;
+ QBENCHMARK {
+ for (int i = 0; i < Iterations; ++i) {
+ Locker locker(&lock);
+ }
+ }
+}
+
+void tst_QReadWriteLock::uncontended_data()
+{
+ QTest::addColumn<FunctionPtrHolder>("holder");
+
+ QTest::newRow("nothing") << FunctionPtrHolder(testUncontended<int, FakeLock>);
+ QTest::newRow("QMutex") << FunctionPtrHolder(testUncontended<QMutex, QMutexLocker>);
+ QTest::newRow("QReadWriteLock, read")
+ << FunctionPtrHolder(testUncontended<QReadWriteLock, QReadLocker>);
+ QTest::newRow("QReadWriteLock, write")
+ << FunctionPtrHolder(testUncontended<QReadWriteLock, QWriteLocker>);
+ QTest::newRow("std::mutex") << FunctionPtrHolder(
+ testUncontended<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#if defined __cpp_lib_shared_timed_mutex
+ QTest::newRow("std::shared_timed_mutex, read") << FunctionPtrHolder(
+ testUncontended<std::shared_timed_mutex,
+ LockerWrapper<std::shared_lock<std::shared_timed_mutex>>>);
+ QTest::newRow("std::shared_timed_mutex, write") << FunctionPtrHolder(
+ testUncontended<std::shared_timed_mutex,
+ LockerWrapper<std::unique_lock<std::shared_timed_mutex>>>);
+#endif
+}
+
+void tst_QReadWriteLock::uncontended()
+{
+ QFETCH(FunctionPtrHolder, holder);
+ holder.value();
+}
+
+static QHash<QString, QString> global_hash;
+
+template <typename Mutex, typename Locker>
+void testReadOnly()
+{
+ struct Thread : QThread
+ {
+ Mutex *lock;
+ void run()
+ {
+ for (int i = 0; i < Iterations; ++i) {
+ QString s = QString::number(i); // Do something outside the lock
+ Locker locker(lock);
+ global_hash.contains(s);
+ }
+ }
+ };
+ Mutex lock;
+ QVector<QThread *> threads;
+ for (int i = 0; i < threadCount; ++i) {
+ auto t = new Thread;
+ t->lock = &lock;
+ threads.append(t);
+ }
+ QBENCHMARK {
+ for (auto t : threads) {
+ t->start();
+ }
+ for (auto t : threads) {
+ t->wait();
+ }
+ }
+ qDeleteAll(threads);
+}
+
+void tst_QReadWriteLock::readOnly_data()
+{
+ QTest::addColumn<FunctionPtrHolder>("holder");
+
+ QTest::newRow("nothing") << FunctionPtrHolder(testReadOnly<int, FakeLock>);
+ QTest::newRow("QMutex") << FunctionPtrHolder(testReadOnly<QMutex, QMutexLocker>);
+ QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testReadOnly<QReadWriteLock, QReadLocker>);
+ QTest::newRow("std::mutex") << FunctionPtrHolder(
+ testReadOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#if defined __cpp_lib_shared_timed_mutex
+ QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder(
+ testReadOnly<std::shared_timed_mutex,
+ LockerWrapper<std::shared_lock<std::shared_timed_mutex>>>);
+#endif
+}
+
+void tst_QReadWriteLock::readOnly()
+{
+ QFETCH(FunctionPtrHolder, holder);
+ holder.value();
+}
+
+QTEST_MAIN(tst_QReadWriteLock)
+#include "tst_qreadwritelock.moc"
diff --git a/tests/benchmarks/corelib/thread/thread.pro b/tests/benchmarks/corelib/thread/thread.pro
index 4e602ceb4e..6b3009bd0c 100644
--- a/tests/benchmarks/corelib/thread/thread.pro
+++ b/tests/benchmarks/corelib/thread/thread.pro
@@ -1,6 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = \
qmutex \
+ qreadwritelock \
qthreadstorage \
qthreadpool \
qwaitcondition \
diff --git a/tests/benchmarks/corelib/tools/containers-sequential/main.cpp b/tests/benchmarks/corelib/tools/containers-sequential/main.cpp
index 9ce8fffa8e..64d3dd5733 100644
--- a/tests/benchmarks/corelib/tools/containers-sequential/main.cpp
+++ b/tests/benchmarks/corelib/tools/containers-sequential/main.cpp
@@ -119,12 +119,7 @@ struct Large { // A "large" item type
int x[1000];
};
-// Embedded devices typically have limited memory
-#if defined(Q_OS_WINCE)
-# define LARGE_MAX_SIZE 2000
-#else
-# define LARGE_MAX_SIZE 20000
-#endif
+#define LARGE_MAX_SIZE 20000
class tst_vector_vs_std : public QObject
{
diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp
index 045beb17f3..5799b32b1c 100644
--- a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp
+++ b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp
@@ -34,15 +34,6 @@
#include <time.h>
-#ifdef Q_OS_WINCE
-// no C89 time() on Windows CE:
-// http://blogs.msdn.com/b/cenet/archive/2006/04/29/time-h-on-windows-ce.aspx
-uint time(void *)
-{
- return uint(-1);
-}
-#endif
-
class tst_bench_QCryptographicHash : public QObject
{
Q_OBJECT