summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/corelib.pro2
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp24
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp5
-rw-r--r--tests/benchmarks/corelib/kernel/kernel.pro3
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp88
-rw-r--r--tests/benchmarks/corelib/text/qbytearray/main.cpp (renamed from tests/benchmarks/corelib/tools/qbytearray/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/text/qbytearray/qbytearray.pro (renamed from tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro)0
-rw-r--r--tests/benchmarks/corelib/text/qchar/main.cpp (renamed from tests/benchmarks/corelib/tools/qchar/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/text/qchar/qchar.pro (renamed from tests/benchmarks/corelib/tools/qchar/qchar.pro)0
-rw-r--r--tests/benchmarks/corelib/text/qlocale/main.cpp (renamed from tests/benchmarks/corelib/tools/qlocale/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/text/qlocale/qlocale.pro (renamed from tests/benchmarks/corelib/tools/qlocale/qlocale.pro)0
-rw-r--r--tests/benchmarks/corelib/text/qregexp/main.cpp (renamed from tests/benchmarks/corelib/tools/qregexp/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/text/qregexp/qregexp.pro (renamed from tests/benchmarks/corelib/tools/qregexp/qregexp.pro)0
-rw-r--r--tests/benchmarks/corelib/text/qregexp/qregexp.qrc (renamed from tests/benchmarks/corelib/tools/qregexp/qregexp.qrc)0
-rw-r--r--tests/benchmarks/corelib/text/qstring/main.cpp (renamed from tests/benchmarks/corelib/tools/qstring/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/text/qstring/qstring.pro (renamed from tests/benchmarks/corelib/tools/qstring/qstring.pro)0
-rw-r--r--tests/benchmarks/corelib/text/qstringbuilder/main.cpp (renamed from tests/benchmarks/corelib/tools/qstringbuilder/main.cpp)2
-rw-r--r--tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro (renamed from tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro)0
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/.gitignore (renamed from tests/benchmarks/corelib/tools/qstringlist/.gitignore)0
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/main.cpp (renamed from tests/benchmarks/corelib/tools/qstringlist/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/qstringlist.pro (renamed from tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro)0
-rw-r--r--tests/benchmarks/corelib/text/text.pro9
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro3
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp91
-rw-r--r--tests/benchmarks/corelib/time/qdate/qdate.pro4
-rw-r--r--tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp213
-rw-r--r--tests/benchmarks/corelib/time/qdatetime/main.cpp574
-rw-r--r--tests/benchmarks/corelib/time/qdatetime/qdatetime.pro (renamed from tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro)0
-rw-r--r--tests/benchmarks/corelib/time/qtimezone/main.cpp (renamed from tests/benchmarks/corelib/tools/qtimezone/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/time/qtimezone/qtimezone.pro (renamed from tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro)0
-rw-r--r--tests/benchmarks/corelib/time/time.pro5
-rw-r--r--tests/benchmarks/corelib/tools/qdatetime/main.cpp604
-rw-r--r--tests/benchmarks/corelib/tools/qhash/paths_small_data.txt56
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qrawvector.h7
-rw-r--r--tests/benchmarks/corelib/tools/tools.pro9
-rw-r--r--tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp28
-rw-r--r--tests/benchmarks/gui/image/qimagereader/qimagereader.pro2
-rw-r--r--tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp17
-rw-r--r--tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp4
-rw-r--r--tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp12
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/benchmarks/opengl/main.cpp5
-rw-r--r--tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp1
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp2
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp2
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp2
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp5
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp12
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp5
-rw-r--r--tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.cpp6
50 files changed, 1069 insertions, 735 deletions
diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro
index b5781ad49e..010abd7751 100644
--- a/tests/benchmarks/corelib/corelib.pro
+++ b/tests/benchmarks/corelib/corelib.pro
@@ -4,7 +4,9 @@ SUBDIRS = \
json \
mimetypes \
kernel \
+ text \
thread \
+ time \
tools \
codecs \
plugin
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index e71daccf7d..eae752d99a 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -78,24 +78,22 @@ void tst_qdiriterator::data()
}
#ifdef Q_OS_WIN
-static int posix_helper(const wchar_t *dirpath)
+static int posix_helper(const wchar_t *dirpath, size_t length)
{
int count = 0;
HANDLE hSearch;
WIN32_FIND_DATA fd;
- const size_t origDirPathLength = wcslen(dirpath);
-
wchar_t appendedPath[MAX_PATH];
- wcscpy(appendedPath, dirpath);
- wcscat(appendedPath, L"\\*");
+ Q_ASSERT(MAX_PATH > length + 3);
+ wcsncpy(appendedPath, dirpath, length);
+ wcscpy(appendedPath + length, L"\\*");
#ifndef Q_OS_WINRT
hSearch = FindFirstFile(appendedPath, &fd);
#else
hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd,
FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
#endif
- appendedPath[origDirPathLength] = 0;
if (hSearch == INVALID_HANDLE_VALUE) {
qWarning("FindFirstFile failed");
@@ -107,10 +105,12 @@ static int posix_helper(const wchar_t *dirpath)
!(fd.cFileName[0] == L'.' && fd.cFileName[1] == L'.' && fd.cFileName[2] == 0))
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- wcscat(appendedPath, L"\\");
- wcscat(appendedPath, fd.cFileName);
- count += posix_helper(appendedPath);
- appendedPath[origDirPathLength] = 0;
+ // newLength will "point" to where we put a * earlier, so we overwrite that.
+ size_t newLength = length + 1; // "+ 1" for directory separator
+ Q_ASSERT(newLength + wcslen(fd.cFileName) + 1 < MAX_PATH); // "+ 1" for null-terminator
+ wcscpy(appendedPath + newLength, fd.cFileName);
+ newLength += wcslen(fd.cFileName);
+ count += posix_helper(appendedPath, newLength);
}
else {
++count;
@@ -164,8 +164,8 @@ void tst_qdiriterator::posix()
QBENCHMARK {
#ifdef Q_OS_WIN
wchar_t wPath[MAX_PATH];
- path.toWCharArray(wPath);
- count = posix_helper(wPath);
+ const int end = path.toWCharArray(wPath);
+ count = posix_helper(wPath, end);
#else
count = posix_helper(dirpath.constData());
#endif
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
index d68264b78f..6ee8b4e93b 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -218,8 +218,9 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path)
#ifdef Q_OS_WIN
wchar_t szSearchPath[MAX_PATH];
- QString::fromLatin1(path).toWCharArray(szSearchPath);
- wcscat(szSearchPath, L"\\*");
+ const int end = QString::fromLatin1(path + "\\*").toWCharArray(szSearchPath);
+ Q_ASSERT(end < MAX_PATH);
+ szSearchPath[end] = L'\0';
#ifndef Q_OS_WINRT
HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult);
#else
diff --git a/tests/benchmarks/corelib/kernel/kernel.pro b/tests/benchmarks/corelib/kernel/kernel.pro
index 02eeeaa254..92f7174419 100644
--- a/tests/benchmarks/corelib/kernel/kernel.pro
+++ b/tests/benchmarks/corelib/kernel/kernel.pro
@@ -5,7 +5,8 @@ SUBDIRS = \
qmetatype \
qobject \
qvariant \
- qcoreapplication
+ qcoreapplication \
+ qtimer_vs_qmetaobject
!qtHaveModule(widgets): SUBDIRS -= \
qmetaobject \
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
index 66a29780f0..6af5b8d586 100644
--- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp
@@ -28,6 +28,7 @@
#include <QtCore>
#include <QtTest/QtTest>
+#include <QThread>
#define INVOKE_COUNT 10000
@@ -35,8 +36,10 @@ class qtimer_vs_qmetaobject : public QObject
{
Q_OBJECT
private slots:
- void testZeroTimerSingleShot();
- void testQueuedInvokeMethod();
+ void bench();
+ void bench_data();
+ void benchBackgroundThread();
+ void benchBackgroundThread_data() { bench_data(); }
};
class InvokeCounter : public QObject {
@@ -47,36 +50,89 @@ public slots:
void invokeSlot() {
count++;
if (count == INVOKE_COUNT)
- QTestEventLoop::instance().exitLoop();
+ emit allInvoked();
}
+signals:
+ void allInvoked();
protected:
int count;
};
-void qtimer_vs_qmetaobject::testZeroTimerSingleShot()
+void qtimer_vs_qmetaobject::bench()
{
+ QFETCH(int, type);
+
+ std::function<void(InvokeCounter*)> invoke;
+ if (type == 0) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, invokeCounter, SLOT(invokeSlot()));
+ };
+ } else if (type == 1) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, invokeCounter, &InvokeCounter::invokeSlot);
+ };
+ } else if (type == 2) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, invokeCounter, [invokeCounter]() {
+ invokeCounter->invokeSlot();
+ });
+ };
+ } else if (type == 3) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QTimer::singleShot(0, [invokeCounter]() {
+ invokeCounter->invokeSlot();
+ });
+ };
+ } else if (type == 4) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QMetaObject::invokeMethod(invokeCounter, "invokeSlot", Qt::QueuedConnection);
+ };
+ } else if (type == 5) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QMetaObject::invokeMethod(invokeCounter, &InvokeCounter::invokeSlot, Qt::QueuedConnection);
+ };
+ } else if (type == 6) {
+ invoke = [](InvokeCounter* invokeCounter) {
+ QMetaObject::invokeMethod(invokeCounter, [invokeCounter]() {
+ invokeCounter->invokeSlot();
+ }, Qt::QueuedConnection);
+ };
+ } else {
+ QFAIL("unhandled data tag");
+ }
+
QBENCHMARK {
InvokeCounter invokeCounter;
+ QSignalSpy spy(&invokeCounter, &InvokeCounter::allInvoked);
for(int i = 0; i < INVOKE_COUNT; ++i) {
- QTimer::singleShot(0, &invokeCounter, SLOT(invokeSlot()));
+ invoke(&invokeCounter);
}
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(spy.wait(10000));
}
}
-void qtimer_vs_qmetaobject::testQueuedInvokeMethod()
+void qtimer_vs_qmetaobject::bench_data()
{
- QBENCHMARK {
- InvokeCounter invokeCounter;
- for(int i = 0; i < INVOKE_COUNT; ++i) {
- QMetaObject::invokeMethod(&invokeCounter, "invokeSlot", Qt::QueuedConnection);
- }
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- }
+ QTest::addColumn<int>("type");
+ QTest::addRow("singleShot_slot") << 0;
+ QTest::addRow("singleShot_pmf") << 1;
+ QTest::addRow("singleShot_functor") << 2;
+ QTest::addRow("singleShot_functor_noctx") << 3;
+ QTest::addRow("invokeMethod_string") << 4;
+ QTest::addRow("invokeMethod_pmf") << 5;
+ QTest::addRow("invokeMethod_functor") << 6;
}
+void qtimer_vs_qmetaobject::benchBackgroundThread()
+{
+#if !QT_CONFIG(cxx11_future)
+ QSKIP("This test requires QThread::create");
+#else
+ QScopedPointer<QThread> thread(QThread::create([this]() { bench(); }));
+ thread->start();
+ QVERIFY(thread->wait());
+#endif
+}
QTEST_MAIN(qtimer_vs_qmetaobject)
diff --git a/tests/benchmarks/corelib/tools/qbytearray/main.cpp b/tests/benchmarks/corelib/text/qbytearray/main.cpp
index e421e7436b..e421e7436b 100644
--- a/tests/benchmarks/corelib/tools/qbytearray/main.cpp
+++ b/tests/benchmarks/corelib/text/qbytearray/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro b/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro
index cf28b0247f..cf28b0247f 100644
--- a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro
+++ b/tests/benchmarks/corelib/text/qbytearray/qbytearray.pro
diff --git a/tests/benchmarks/corelib/tools/qchar/main.cpp b/tests/benchmarks/corelib/text/qchar/main.cpp
index 4dcf86786d..4dcf86786d 100644
--- a/tests/benchmarks/corelib/tools/qchar/main.cpp
+++ b/tests/benchmarks/corelib/text/qchar/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qchar/qchar.pro b/tests/benchmarks/corelib/text/qchar/qchar.pro
index 80a9861f48..80a9861f48 100644
--- a/tests/benchmarks/corelib/tools/qchar/qchar.pro
+++ b/tests/benchmarks/corelib/text/qchar/qchar.pro
diff --git a/tests/benchmarks/corelib/tools/qlocale/main.cpp b/tests/benchmarks/corelib/text/qlocale/main.cpp
index 38d94af143..38d94af143 100644
--- a/tests/benchmarks/corelib/tools/qlocale/main.cpp
+++ b/tests/benchmarks/corelib/text/qlocale/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qlocale/qlocale.pro b/tests/benchmarks/corelib/text/qlocale/qlocale.pro
index e56bbe0341..e56bbe0341 100644
--- a/tests/benchmarks/corelib/tools/qlocale/qlocale.pro
+++ b/tests/benchmarks/corelib/text/qlocale/qlocale.pro
diff --git a/tests/benchmarks/corelib/tools/qregexp/main.cpp b/tests/benchmarks/corelib/text/qregexp/main.cpp
index 798b23f2b0..798b23f2b0 100644
--- a/tests/benchmarks/corelib/tools/qregexp/main.cpp
+++ b/tests/benchmarks/corelib/text/qregexp/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/text/qregexp/qregexp.pro
index f64ae781a2..f64ae781a2 100644
--- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro
+++ b/tests/benchmarks/corelib/text/qregexp/qregexp.pro
diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.qrc b/tests/benchmarks/corelib/text/qregexp/qregexp.qrc
index a7fe13c035..a7fe13c035 100644
--- a/tests/benchmarks/corelib/tools/qregexp/qregexp.qrc
+++ b/tests/benchmarks/corelib/text/qregexp/qregexp.qrc
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/text/qstring/main.cpp
index 826a843c10..826a843c10 100644
--- a/tests/benchmarks/corelib/tools/qstring/main.cpp
+++ b/tests/benchmarks/corelib/text/qstring/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qstring/qstring.pro b/tests/benchmarks/corelib/text/qstring/qstring.pro
index 9f5e34b915..9f5e34b915 100644
--- a/tests/benchmarks/corelib/tools/qstring/qstring.pro
+++ b/tests/benchmarks/corelib/text/qstring/qstring.pro
diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp b/tests/benchmarks/corelib/text/qstringbuilder/main.cpp
index d0dfe3b1a7..0de6d33846 100644
--- a/tests/benchmarks/corelib/tools/qstringbuilder/main.cpp
+++ b/tests/benchmarks/corelib/text/qstringbuilder/main.cpp
@@ -401,7 +401,7 @@ private slots:
}
private:
- const QLatin1Literal l1literal;
+ const QLatin1String l1literal;
const QLatin1String l1string;
const QByteArray ba;
const QString string;
diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro
index fa4cbe3c13..fa4cbe3c13 100644
--- a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro
+++ b/tests/benchmarks/corelib/text/qstringbuilder/qstringbuilder.pro
diff --git a/tests/benchmarks/corelib/tools/qstringlist/.gitignore b/tests/benchmarks/corelib/text/qstringlist/.gitignore
index 3e0cdc952f..3e0cdc952f 100644
--- a/tests/benchmarks/corelib/tools/qstringlist/.gitignore
+++ b/tests/benchmarks/corelib/text/qstringlist/.gitignore
diff --git a/tests/benchmarks/corelib/tools/qstringlist/main.cpp b/tests/benchmarks/corelib/text/qstringlist/main.cpp
index ae355a8b89..ae355a8b89 100644
--- a/tests/benchmarks/corelib/tools/qstringlist/main.cpp
+++ b/tests/benchmarks/corelib/text/qstringlist/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro
index 5803e7da0e..5803e7da0e 100644
--- a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro
+++ b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro
diff --git a/tests/benchmarks/corelib/text/text.pro b/tests/benchmarks/corelib/text/text.pro
new file mode 100644
index 0000000000..a2397b37fe
--- /dev/null
+++ b/tests/benchmarks/corelib/text/text.pro
@@ -0,0 +1,9 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ qbytearray \
+ qchar \
+ qlocale \
+ qstringbuilder \
+ qstringlist
+
+*g++*: SUBDIRS += qstring
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
index 86102adecd..a1827d0276 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/qreadwritelock.pro
@@ -1,6 +1,7 @@
TEMPLATE = app
TARGET = tst_bench_qreadwritelock
-QT = core testlib
+QT = core-private testlib
SOURCES += tst_qreadwritelock.cpp
CONFIG += c++14 # for std::shared_timed_mutex
+CONFIG += c++1z # for std::shared_mutex
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index fcf600a059..1d47d98657 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -28,12 +28,14 @@
#include <QtCore/QtCore>
#include <QtTest/QtTest>
+#include <QtCore/private/qmemory_p.h>
#include <mutex>
#if QT_HAS_INCLUDE(<shared_mutex>)
#if __cplusplus > 201103L
#include <shared_mutex>
#endif
#endif
+#include <vector>
// Wrapers that take pointers instead of reference to have the same interface as Qt
template <typename T>
@@ -63,6 +65,8 @@ private slots:
void uncontended();
void readOnly_data();
void readOnly();
+ void writeOnly_data();
+ void writeOnly();
// void readWrite();
};
@@ -106,6 +110,14 @@ void tst_QReadWriteLock::uncontended_data()
<< FunctionPtrHolder(testUncontended<QReadWriteLock, QWriteLocker>);
QTest::newRow("std::mutex") << FunctionPtrHolder(
testUncontended<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#ifdef __cpp_lib_shared_mutex
+ QTest::newRow("std::shared_mutex, read") << FunctionPtrHolder(
+ testUncontended<std::shared_mutex,
+ LockerWrapper<std::shared_lock<std::shared_mutex>>>);
+ QTest::newRow("std::shared_mutex, write") << FunctionPtrHolder(
+ testUncontended<std::shared_mutex,
+ LockerWrapper<std::unique_lock<std::shared_mutex>>>);
+#endif
#if defined __cpp_lib_shared_timed_mutex
QTest::newRow("std::shared_timed_mutex, read") << FunctionPtrHolder(
testUncontended<std::shared_timed_mutex,
@@ -130,7 +142,7 @@ void testReadOnly()
struct Thread : QThread
{
Mutex *lock;
- void run()
+ void run() override
{
for (int i = 0; i < Iterations; ++i) {
QString s = QString::number(i); // Do something outside the lock
@@ -140,21 +152,20 @@ void testReadOnly()
}
};
Mutex lock;
- QVector<QThread *> threads;
+ std::vector<std::unique_ptr<Thread>> threads;
for (int i = 0; i < threadCount; ++i) {
- auto t = new Thread;
+ auto t = qt_make_unique<Thread>();
t->lock = &lock;
- threads.append(t);
+ threads.push_back(std::move(t));
}
QBENCHMARK {
- for (auto t : threads) {
+ for (auto &t : threads) {
t->start();
}
- for (auto t : threads) {
+ for (auto &t : threads) {
t->wait();
}
}
- qDeleteAll(threads);
}
void tst_QReadWriteLock::readOnly_data()
@@ -166,6 +177,11 @@ void tst_QReadWriteLock::readOnly_data()
QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testReadOnly<QReadWriteLock, QReadLocker>);
QTest::newRow("std::mutex") << FunctionPtrHolder(
testReadOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#ifdef __cpp_lib_shared_mutex
+ QTest::newRow("std::shared_mutex") << FunctionPtrHolder(
+ testReadOnly<std::shared_mutex,
+ LockerWrapper<std::shared_lock<std::shared_mutex>>>);
+#endif
#if defined __cpp_lib_shared_timed_mutex
QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder(
testReadOnly<std::shared_timed_mutex,
@@ -179,5 +195,66 @@ void tst_QReadWriteLock::readOnly()
holder.value();
}
+static QString global_string;
+
+template <typename Mutex, typename Locker>
+void testWriteOnly()
+{
+ struct Thread : QThread
+ {
+ Mutex *lock;
+ void run() override
+ {
+ for (int i = 0; i < Iterations; ++i) {
+ QString s = QString::number(i); // Do something outside the lock
+ Locker locker(lock);
+ global_string = s;
+ }
+ }
+ };
+ Mutex lock;
+ std::vector<std::unique_ptr<Thread>> threads;
+ for (int i = 0; i < threadCount; ++i) {
+ auto t = qt_make_unique<Thread>();
+ t->lock = &lock;
+ threads.push_back(std::move(t));
+ }
+ QBENCHMARK {
+ for (auto &t : threads) {
+ t->start();
+ }
+ for (auto &t : threads) {
+ t->wait();
+ }
+ }
+}
+
+void tst_QReadWriteLock::writeOnly_data()
+{
+ QTest::addColumn<FunctionPtrHolder>("holder");
+
+ // QTest::newRow("nothing") << FunctionPtrHolder(testWriteOnly<int, FakeLock>);
+ QTest::newRow("QMutex") << FunctionPtrHolder(testWriteOnly<QMutex, QMutexLocker>);
+ QTest::newRow("QReadWriteLock") << FunctionPtrHolder(testWriteOnly<QReadWriteLock, QWriteLocker>);
+ QTest::newRow("std::mutex") << FunctionPtrHolder(
+ testWriteOnly<std::mutex, LockerWrapper<std::unique_lock<std::mutex>>>);
+#ifdef __cpp_lib_shared_mutex
+ QTest::newRow("std::shared_mutex") << FunctionPtrHolder(
+ testWriteOnly<std::shared_mutex,
+ LockerWrapper<std::unique_lock<std::shared_mutex>>>);
+#endif
+#if defined __cpp_lib_shared_timed_mutex
+ QTest::newRow("std::shared_timed_mutex") << FunctionPtrHolder(
+ testWriteOnly<std::shared_timed_mutex,
+ LockerWrapper<std::unique_lock<std::shared_timed_mutex>>>);
+#endif
+}
+
+void tst_QReadWriteLock::writeOnly()
+{
+ QFETCH(FunctionPtrHolder, holder);
+ holder.value();
+}
+
QTEST_MAIN(tst_QReadWriteLock)
#include "tst_qreadwritelock.moc"
diff --git a/tests/benchmarks/corelib/time/qdate/qdate.pro b/tests/benchmarks/corelib/time/qdate/qdate.pro
new file mode 100644
index 0000000000..a655917135
--- /dev/null
+++ b/tests/benchmarks/corelib/time/qdate/qdate.pro
@@ -0,0 +1,4 @@
+TARGET = tst_bench_qdate
+QT = core testlib
+
+SOURCES += tst_bench_qdate.cpp
diff --git a/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp
new file mode 100644
index 0000000000..10c013c080
--- /dev/null
+++ b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module 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 <QDate>
+#include <QTest>
+#include <QVector>
+
+class tst_QDate : public QObject
+{
+ Q_OBJECT
+
+ enum : qint64
+ {
+ JULIAN_DAY_2010 = 2455198,
+ JULIAN_DAY_2011 = 2455563,
+ JULIAN_DAY_2020 = 2458850,
+ };
+
+ static QVector<QDate> daily(qint64 start, qint64 end);
+ static QVector<QDate> yearly(qint32 first, qint32 last);
+
+private Q_SLOTS:
+ void create();
+ void year();
+ void month();
+ void day();
+ void dayOfWeek();
+ void dayOfYear();
+ void monthLengths(); // isValid() and daysInMonth()
+ void daysInYear();
+ void isLeapYear();
+ void getSetDate();
+ void addDays();
+ void addMonths();
+ void addYears();
+};
+
+QVector<QDate> tst_QDate::daily(qint64 start, qint64 end)
+{
+ QVector<QDate> list;
+ list.reserve(end - start);
+ for (qint64 jd = start; jd < end; ++jd)
+ list.append(QDate::fromJulianDay(jd));
+ return list;
+}
+
+QVector<QDate> tst_QDate::yearly(qint32 first, qint32 last)
+{
+ QVector<QDate> list;
+ list.reserve(last + 1 - first);
+ for (qint32 year = first; year <= last; ++year)
+ list.append(QDate(year, 3, 21));
+ return list;
+}
+
+void tst_QDate::create()
+{
+ QDate test;
+ QBENCHMARK {
+ for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
+ test = QDate::fromJulianDay(jd);
+ }
+ Q_UNUSED(test);
+}
+
+void tst_QDate::year()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDate &test : list)
+ test.year();
+ }
+}
+
+void tst_QDate::month()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDate &test : list)
+ test.month();
+ }
+}
+
+void tst_QDate::day()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDate &test : list)
+ test.day();
+ }
+}
+
+void tst_QDate::dayOfWeek()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDate &test : list)
+ test.dayOfWeek();
+ }
+}
+
+void tst_QDate::dayOfYear()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDate &test : list)
+ test.dayOfYear();
+ }
+}
+
+void tst_QDate::monthLengths()
+{
+ bool check = true;
+ QBENCHMARK {
+ for (int year = 1900; year <= 2100; year++) {
+ for (int month = 1; month <= 12; month++)
+ check = QDate::isValid(year, month, QDate(year, month, 1).daysInMonth());
+ }
+ }
+ Q_UNUSED(check);
+}
+
+void tst_QDate::daysInYear()
+{
+ const auto list = yearly(1601, 2401);
+ QBENCHMARK {
+ for (const QDate date : list)
+ date.daysInYear();
+ }
+}
+
+void tst_QDate::isLeapYear()
+{
+ QBENCHMARK {
+ for (qint32 year = 1601; year <= 2401; year++)
+ QDate::isLeapYear(year);
+ }
+}
+
+void tst_QDate::getSetDate()
+{
+ QDate store;
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const auto test : list) {
+ int year, month, day;
+ test.getDate(&year, &month, &day);
+ store.setDate(year, month, day);
+ }
+ }
+ Q_UNUSED(store);
+}
+
+void tst_QDate::addDays()
+{
+ QDate store;
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const auto test : list)
+ store = test.addDays(17);
+ }
+ Q_UNUSED(store);
+}
+
+void tst_QDate::addMonths()
+{
+ QDate store;
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const auto test : list)
+ store = test.addMonths(17);
+ }
+ Q_UNUSED(store);
+}
+
+void tst_QDate::addYears()
+{
+ QDate store;
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const auto test : list)
+ store = test.addYears(17);
+ }
+ Q_UNUSED(store);
+}
+
+QTEST_MAIN(tst_QDate)
+#include "tst_bench_qdate.moc"
diff --git a/tests/benchmarks/corelib/time/qdatetime/main.cpp b/tests/benchmarks/corelib/time/qdatetime/main.cpp
new file mode 100644
index 0000000000..740e08cc46
--- /dev/null
+++ b/tests/benchmarks/corelib/time/qdatetime/main.cpp
@@ -0,0 +1,574 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module 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 <QDateTime>
+#include <QTimeZone>
+#include <QTest>
+#include <QVector>
+#include <qdebug.h>
+
+class tst_QDateTime : public QObject
+{
+ Q_OBJECT
+
+ enum : qint64
+ {
+ SECS_PER_DAY = 86400,
+ MSECS_PER_DAY = 86400000,
+ JULIAN_DAY_1950 = 2433283,
+ JULIAN_DAY_1960 = 2436935,
+ JULIAN_DAY_1970 = 2440588, // Epoch
+ JULIAN_DAY_2010 = 2455198,
+ JULIAN_DAY_2011 = 2455563,
+ JULIAN_DAY_2020 = 2458850,
+ JULIAN_DAY_2050 = 2469808,
+ JULIAN_DAY_2060 = 2473460
+ };
+
+ static QVector<QDateTime> daily(qint64 start, qint64 end);
+ static QVector<QDateTime> norse(qint64 start, qint64 end);
+
+private Q_SLOTS:
+ void create();
+ void isNull();
+ void isValid();
+ void date();
+ void time();
+ void timeSpec();
+ void offsetFromUtc();
+ void timeZoneAbbreviation();
+ void toMSecsSinceEpoch();
+ void toMSecsSinceEpoch1950();
+ void toMSecsSinceEpoch2050();
+ void toMSecsSinceEpochTz();
+ void toMSecsSinceEpoch1950Tz();
+ void toMSecsSinceEpoch2050Tz();
+ void setDate();
+ void setTime();
+ void setTimeSpec();
+ void setOffsetFromUtc();
+ void setMSecsSinceEpoch();
+ void setMSecsSinceEpochTz();
+ void toString();
+ void toStringTextFormat();
+ void toStringIsoFormat();
+ void addDays();
+ void addDaysTz();
+ void addMSecs();
+ void addMSecsTz();
+ void toTimeSpec();
+ void toOffsetFromUtc();
+ void daysTo();
+ void msecsTo();
+ void equivalent();
+ void equivalentUtc();
+ void lessThan();
+ void lessThanUtc();
+ void currentDateTime();
+ void currentDate();
+ void currentTime();
+ void currentDateTimeUtc();
+ void currentMSecsSinceEpoch();
+ void fromString();
+ void fromStringText();
+ void fromStringIso();
+ void fromMSecsSinceEpoch();
+ void fromMSecsSinceEpochUtc();
+ void fromMSecsSinceEpochTz();
+};
+
+QVector<QDateTime> tst_QDateTime::daily(qint64 start, qint64 end)
+{
+ QVector<QDateTime> list;
+ list.reserve(end - start);
+ for (int jd = start; jd < end; ++jd)
+ list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
+ return list;
+}
+
+QVector<QDateTime> tst_QDateTime::norse(qint64 start, qint64 end)
+{
+ const QTimeZone cet("Europe/Oslo");
+ QVector<QDateTime> list;
+ list.reserve(end - start);
+ for (int jd = start; jd < end; ++jd)
+ list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
+ return list;
+}
+
+void tst_QDateTime::create()
+{
+ QBENCHMARK {
+ for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) {
+ QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0));
+ Q_UNUSED(test)
+ }
+ }
+}
+
+void tst_QDateTime::isNull()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.isNull();
+ }
+}
+
+void tst_QDateTime::isValid()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.isValid();
+ }
+}
+
+void tst_QDateTime::date()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.date();
+ }
+}
+
+void tst_QDateTime::time()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.time();
+ }
+}
+
+void tst_QDateTime::timeSpec()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.timeSpec();
+ }
+}
+
+void tst_QDateTime::offsetFromUtc()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.offsetFromUtc();
+ }
+}
+
+void tst_QDateTime::timeZoneAbbreviation()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.timeZoneAbbreviation();
+ }
+}
+
+void tst_QDateTime::toMSecsSinceEpoch()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toMSecsSinceEpoch();
+ }
+}
+
+void tst_QDateTime::toMSecsSinceEpoch1950()
+{
+ const auto list = daily(JULIAN_DAY_1950, JULIAN_DAY_1960);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toMSecsSinceEpoch();
+ }
+}
+
+void tst_QDateTime::toMSecsSinceEpoch2050()
+{
+ const auto list = daily(JULIAN_DAY_2050, JULIAN_DAY_2060);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toMSecsSinceEpoch();
+ }
+}
+
+void tst_QDateTime::toMSecsSinceEpochTz()
+{
+ qint64 result;
+ const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = test.toMSecsSinceEpoch();
+ }
+ Q_UNUSED(result);
+}
+
+void tst_QDateTime::toMSecsSinceEpoch1950Tz()
+{
+ qint64 result;
+ const auto list = norse(JULIAN_DAY_1950, JULIAN_DAY_1960);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = test.toMSecsSinceEpoch();
+ }
+ Q_UNUSED(result);
+}
+
+void tst_QDateTime::toMSecsSinceEpoch2050Tz()
+{
+ qint64 result;
+ const auto list = norse(JULIAN_DAY_2050, JULIAN_DAY_2060);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = test.toMSecsSinceEpoch();
+ }
+ Q_UNUSED(result);
+}
+
+void tst_QDateTime::setDate()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (QDateTime test : list)
+ test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010));
+ }
+}
+
+void tst_QDateTime::setTime()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (QDateTime test : list)
+ test.setTime(QTime(12, 0, 0));
+ }
+}
+
+void tst_QDateTime::setTimeSpec()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (QDateTime test : list)
+ test.setTimeSpec(Qt::UTC);
+ }
+}
+
+void tst_QDateTime::setOffsetFromUtc()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (QDateTime test : list)
+ test.setOffsetFromUtc(3600);
+ }
+}
+
+void tst_QDateTime::setMSecsSinceEpoch()
+{
+ qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY;
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (QDateTime test : list)
+ test.setMSecsSinceEpoch(msecs);
+ }
+}
+
+void tst_QDateTime::setMSecsSinceEpochTz()
+{
+ const qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY;
+ const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (QDateTime test : list)
+ test.setMSecsSinceEpoch(msecs);
+ }
+}
+
+void tst_QDateTime::toString()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t"));
+ }
+}
+
+void tst_QDateTime::toStringTextFormat()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toString(Qt::TextDate);
+ }
+}
+
+void tst_QDateTime::toStringIsoFormat()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toString(Qt::ISODate);
+ }
+}
+
+void tst_QDateTime::addDays()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QDateTime next;
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ next = test.addDays(1);
+ }
+ Q_UNUSED(next);
+}
+
+void tst_QDateTime::addDaysTz()
+{
+ const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ QDateTime result = test.addDays(1);
+ }
+}
+
+void tst_QDateTime::addMSecs()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QDateTime next;
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ next = test.addMSecs(1);
+ }
+ Q_UNUSED(next);
+}
+
+void tst_QDateTime::addMSecsTz()
+{
+ const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ QDateTime result = test.addMSecs(1);
+ }
+}
+
+void tst_QDateTime::toTimeSpec()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toTimeSpec(Qt::UTC);
+ }
+}
+
+void tst_QDateTime::toOffsetFromUtc()
+{
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.toOffsetFromUtc(3600);
+ }
+}
+
+void tst_QDateTime::daysTo()
+{
+ const QDateTime other = QDateTime::fromMSecsSinceEpoch(
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.daysTo(other);
+ }
+}
+
+void tst_QDateTime::msecsTo()
+{
+ const QDateTime other = QDateTime::fromMSecsSinceEpoch(
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ test.msecsTo(other);
+ }
+}
+
+void tst_QDateTime::equivalent()
+{
+ bool result;
+ const QDateTime other = QDateTime::fromMSecsSinceEpoch(
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = (test == other);
+ }
+ Q_UNUSED(result)
+}
+
+void tst_QDateTime::equivalentUtc()
+{
+ bool result = false;
+ const QDateTime other = QDateTime::fromMSecsSinceEpoch(
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC);
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = (test == other);
+ }
+ Q_UNUSED(result)
+}
+
+void tst_QDateTime::lessThan()
+{
+ bool result = false;
+ const QDateTime other = QDateTime::fromMSecsSinceEpoch(
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY);
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = (test < other);
+ }
+ Q_UNUSED(result)
+}
+
+void tst_QDateTime::lessThanUtc()
+{
+ bool result = false;
+ const QDateTime other = QDateTime::fromMSecsSinceEpoch(
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC);
+ const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
+ QBENCHMARK {
+ for (const QDateTime &test : list)
+ result = (test < other);
+ }
+ Q_UNUSED(result)
+}
+
+void tst_QDateTime::currentDateTime()
+{
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDateTime::currentDateTime();
+ }
+}
+
+void tst_QDateTime::currentDate()
+{
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDate::currentDate();
+ }
+}
+
+void tst_QDateTime::currentTime()
+{
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QTime::currentTime();
+ }
+}
+
+void tst_QDateTime::currentDateTimeUtc()
+{
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDateTime::currentDateTimeUtc();
+ }
+}
+
+void tst_QDateTime::currentMSecsSinceEpoch()
+{
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDateTime::currentMSecsSinceEpoch();
+ }
+}
+
+void tst_QDateTime::fromString()
+{
+ QString format = "yyyy-MM-dd hh:mm:ss.zzz";
+ QString input = "2010-01-01 13:12:11.999";
+ QVERIFY(QDateTime::fromString(input, format).isValid());
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDateTime::fromString(input, format);
+ }
+}
+
+void tst_QDateTime::fromStringText()
+{
+ QString input = "Wed Jan 2 01:02:03.000 2013 GMT";
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDateTime::fromString(input, Qt::TextDate);
+ }
+}
+
+void tst_QDateTime::fromStringIso()
+{
+ QString input = "2010-01-01T13:28:34.999Z";
+ QBENCHMARK {
+ for (int i = 0; i < 1000; ++i)
+ QDateTime::fromString(input, Qt::ISODate);
+ }
+}
+
+void tst_QDateTime::fromMSecsSinceEpoch()
+{
+ const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
+ const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970;
+ QBENCHMARK {
+ for (int jd = start; jd < end; ++jd)
+ QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime);
+ }
+}
+
+void tst_QDateTime::fromMSecsSinceEpochUtc()
+{
+ const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
+ const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970;
+ QBENCHMARK {
+ for (int jd = start; jd < end; ++jd)
+ QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC);
+ }
+}
+
+void tst_QDateTime::fromMSecsSinceEpochTz()
+{
+ const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
+ const int end = JULIAN_DAY_2020 - JULIAN_DAY_1970;
+ const QTimeZone cet("Europe/Oslo");
+ QBENCHMARK {
+ for (int jd = start; jd < end; ++jd)
+ QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet);
+ }
+}
+
+QTEST_MAIN(tst_QDateTime)
+
+#include "main.moc"
diff --git a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro
index a85e7346c6..a85e7346c6 100644
--- a/tests/benchmarks/corelib/tools/qdatetime/qdatetime.pro
+++ b/tests/benchmarks/corelib/time/qdatetime/qdatetime.pro
diff --git a/tests/benchmarks/corelib/tools/qtimezone/main.cpp b/tests/benchmarks/corelib/time/qtimezone/main.cpp
index 65455a7261..65455a7261 100644
--- a/tests/benchmarks/corelib/tools/qtimezone/main.cpp
+++ b/tests/benchmarks/corelib/time/qtimezone/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro
index d0531b568b..d0531b568b 100644
--- a/tests/benchmarks/corelib/tools/qtimezone/qtimezone.pro
+++ b/tests/benchmarks/corelib/time/qtimezone/qtimezone.pro
diff --git a/tests/benchmarks/corelib/time/time.pro b/tests/benchmarks/corelib/time/time.pro
new file mode 100644
index 0000000000..b5184845d9
--- /dev/null
+++ b/tests/benchmarks/corelib/time/time.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ qdate \
+ qdatetime \
+ qtimezone
diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
deleted file mode 100644
index 2c1e3d97ae..0000000000
--- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp
+++ /dev/null
@@ -1,604 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 <QDateTime>
-#include <QTimeZone>
-#include <QTest>
-#include <qdebug.h>
-
-class tst_QDateTime : public QObject
-{
- Q_OBJECT
-
- enum
-#if defined(Q_COMPILER_CLASS_ENUM) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700)
- : qint64
-#endif
- {
- SECS_PER_DAY = 86400,
- MSECS_PER_DAY = 86400000,
- JULIAN_DAY_1950 = 2433283,
- JULIAN_DAY_1960 = 2436935,
- JULIAN_DAY_2010 = 2455198,
- JULIAN_DAY_2011 = 2455563,
- JULIAN_DAY_2020 = 2458850,
- JULIAN_DAY_2050 = 2469808,
- JULIAN_DAY_2060 = 2473460
- };
-
-private Q_SLOTS:
- void create();
- void isNull();
- void isValid();
- void date();
- void time();
- void timeSpec();
- void offsetFromUtc();
- void timeZoneAbbreviation();
- void toMSecsSinceEpoch();
- void toMSecsSinceEpoch1950();
- void toMSecsSinceEpoch2050();
- void toMSecsSinceEpochTz();
- void toMSecsSinceEpoch1950Tz();
- void toMSecsSinceEpoch2050Tz();
- void setDate();
- void setTime();
- void setTimeSpec();
- void setOffsetFromUtc();
- void setMSecsSinceEpoch();
- void setMSecsSinceEpochTz();
- void toString();
- void toStringTextFormat();
- void toStringIsoFormat();
- void addDays();
- void addDaysTz();
- void addMSecs();
- void addMSecsTz();
- void toTimeSpec();
- void toOffsetFromUtc();
- void daysTo();
- void msecsTo();
- void equivalent();
- void equivalentUtc();
- void lessThan();
- void lessThanUtc();
- void currentDateTime();
- void currentDate();
- void currentTime();
- void currentDateTimeUtc();
- void currentMSecsSinceEpoch();
- void fromString();
- void fromStringText();
- void fromStringIso();
- void fromMSecsSinceEpoch();
- void fromMSecsSinceEpochUtc();
- void fromMSecsSinceEpochTz();
-};
-
-void tst_QDateTime::create()
-{
- QBENCHMARK {
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd) {
- QDateTime test(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0));
- Q_UNUSED(test)
- }
- }
-}
-
-void tst_QDateTime::isNull()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.isNull();
- }
-}
-
-void tst_QDateTime::isValid()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.isValid();
- }
-}
-
-void tst_QDateTime::date()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.date();
- }
-}
-
-void tst_QDateTime::time()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.time();
- }
-}
-
-void tst_QDateTime::timeSpec()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.timeSpec();
- }
-}
-
-void tst_QDateTime::offsetFromUtc()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.offsetFromUtc();
- }
-}
-
-void tst_QDateTime::timeZoneAbbreviation()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.timeZoneAbbreviation();
- }
-}
-
-void tst_QDateTime::toMSecsSinceEpoch()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::toMSecsSinceEpoch1950()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::toMSecsSinceEpoch2050()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::toMSecsSinceEpochTz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- qint64 result = test.toMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::toMSecsSinceEpoch1950Tz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_1950; jd < JULIAN_DAY_1960; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- qint64 result = test.toMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::toMSecsSinceEpoch2050Tz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2050; jd < JULIAN_DAY_2060; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- qint64 result = test.toMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::setDate()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (QDateTime test, list)
- test.setDate(QDate::fromJulianDay(JULIAN_DAY_2010));
- }
-}
-
-void tst_QDateTime::setTime()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (QDateTime test, list)
- test.setTime(QTime(12, 0, 0));
- }
-}
-
-void tst_QDateTime::setTimeSpec()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (QDateTime test, list)
- test.setTimeSpec(Qt::UTC);
- }
-}
-
-void tst_QDateTime::setOffsetFromUtc()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (QDateTime test, list)
- test.setOffsetFromUtc(3600);
- }
-}
-
-void tst_QDateTime::setMSecsSinceEpoch()
-{
- qint64 msecs = qint64(JULIAN_DAY_2010 + 180) * MSECS_PER_DAY;
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (QDateTime test, list)
- test.setMSecsSinceEpoch(msecs);
- }
-}
-
-void tst_QDateTime::setMSecsSinceEpochTz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
- QBENCHMARK {
- foreach (QDateTime test, list)
- test.setMSecsSinceEpoch((JULIAN_DAY_2010 + 180) * MSECS_PER_DAY);
- }
-}
-
-void tst_QDateTime::toString()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toString(QStringLiteral("yyy-MM-dd hh:mm:ss.zzz t"));
- }
-}
-
-void tst_QDateTime::toStringTextFormat()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toString(Qt::TextDate);
- }
-}
-
-void tst_QDateTime::toStringIsoFormat()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2011; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toString(Qt::ISODate);
- }
-}
-
-void tst_QDateTime::addDays()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.addDays(1);
- }
-}
-
-void tst_QDateTime::addDaysTz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- QDateTime result = test.addDays(1);
- }
-}
-
-void tst_QDateTime::addMSecs()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.addMSecs(1);
- }
-}
-
-void tst_QDateTime::addMSecsTz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0), cet));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- QDateTime result = test.addMSecs(1);
- }
-}
-
-void tst_QDateTime::toTimeSpec()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toTimeSpec(Qt::UTC);
- }
-}
-
-void tst_QDateTime::toOffsetFromUtc()
-{
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.toOffsetFromUtc(3600);
- }
-}
-
-void tst_QDateTime::daysTo()
-{
- QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.daysTo(other);
- }
-}
-
-void tst_QDateTime::msecsTo()
-{
- QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- test.msecsTo(other);
- }
-}
-
-void tst_QDateTime::equivalent()
-{
- bool result;
- QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- result = (test == other);
- }
- Q_UNUSED(result)
-}
-
-void tst_QDateTime::equivalentUtc()
-{
- bool result = false;
- QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC);
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- result = (test == other);
- }
- Q_UNUSED(result)
-}
-
-void tst_QDateTime::lessThan()
-{
- bool result = false;
- QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY);
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- result = (test < other);
- }
- Q_UNUSED(result)
-}
-
-void tst_QDateTime::lessThanUtc()
-{
- bool result = false;
- QDateTime other = QDateTime::fromMSecsSinceEpoch(qint64(JULIAN_DAY_2010) * MSECS_PER_DAY, Qt::UTC);
- QList<QDateTime> list;
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- list.append(QDateTime(QDate::fromJulianDay(jd), QTime::fromMSecsSinceStartOfDay(0)));
- QBENCHMARK {
- foreach (const QDateTime &test, list)
- result = (test < other);
- }
- Q_UNUSED(result)
-}
-
-void tst_QDateTime::currentDateTime()
-{
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDateTime::currentDateTime();
- }
-}
-
-void tst_QDateTime::currentDate()
-{
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDate::currentDate();
- }
-}
-
-void tst_QDateTime::currentTime()
-{
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QTime::currentTime();
- }
-}
-
-void tst_QDateTime::currentDateTimeUtc()
-{
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDateTime::currentDateTimeUtc();
- }
-}
-
-void tst_QDateTime::currentMSecsSinceEpoch()
-{
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDateTime::currentMSecsSinceEpoch();
- }
-}
-
-void tst_QDateTime::fromString()
-{
- QString format = "yyyy-MM-dd hh:mm:ss.zzz";
- QString input = "2010-01-01 13:12:11.999";
- QVERIFY(QDateTime::fromString(input, format).isValid());
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDateTime::fromString(input, format);
- }
-}
-
-void tst_QDateTime::fromStringText()
-{
- QString input = "Wed Jan 2 01:02:03.000 2013 GMT";
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDateTime::fromString(input, Qt::TextDate);
- }
-}
-
-void tst_QDateTime::fromStringIso()
-{
- QString input = "2010-01-01T13:28:34.999Z";
- QBENCHMARK {
- for (int i = 0; i < 1000; ++i)
- QDateTime::fromString(input, Qt::ISODate);
- }
-}
-
-void tst_QDateTime::fromMSecsSinceEpoch()
-{
- QBENCHMARK {
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::LocalTime);
- }
-}
-
-void tst_QDateTime::fromMSecsSinceEpochUtc()
-{
- QBENCHMARK {
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, Qt::UTC);
- }
-}
-
-void tst_QDateTime::fromMSecsSinceEpochTz()
-{
- QTimeZone cet = QTimeZone("Europe/Oslo");
- QBENCHMARK {
- for (int jd = JULIAN_DAY_2010; jd < JULIAN_DAY_2020; ++jd)
- QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet);
- }
-}
-
-QTEST_MAIN(tst_QDateTime)
-
-#include "main.moc"
diff --git a/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt b/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt
index d5acd28820..662285296f 100644
--- a/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt
+++ b/tests/benchmarks/corelib/tools/qhash/paths_small_data.txt
@@ -47,13 +47,38 @@
./codecs/.obj/debug-shared
./.pch
./.pch/debug-shared
+./text
+./text/text.pro
+./text/qregexp
+./text/qregexp/qregexp.qrc
+./text/qregexp/main.cpp
+./text/qregexp/Makefile
+./text/qregexp/qregexp.pro
+./text/qstringbuilder
+./text/qstringbuilder/main.cpp
+./text/qstringbuilder/Makefile
+./text/qstringbuilder/qstringbuilder.pro
+./text/qstring
+./text/qstring/generatelist.pl
+./text/qstring/data.h
+./text/qstring/qstring.pro
+./text/qstring/main.cpp
+./text/qstring/data.cpp
+./text/qstring/Makefile
+./text/qstring/utf-8.txt
+./text/qstringlist
+./text/qstringlist/qstringlist.pro
+./text/qstringlist/main.cpp
+./text/qstringlist/.gitignore
+./text/qstringlist/Makefile
+./text/qbytearray
+./text/qbytearray/qbytearray.pro
+./text/qbytearray/main.cpp
+./text/qbytearray/Makefile
+./text/.pch
+./text/.pch/debug-shared
./tools
./tools/tools.pro
-./tools/qregexp
-./tools/qregexp/qregexp.qrc
-./tools/qregexp/main.cpp
-./tools/qregexp/Makefile
-./tools/qregexp/qregexp.pro
./tools/qvector
./tools/qvector/tst_vector
./tools/qvector/.pch
@@ -72,31 +97,10 @@
./tools/qvector/qvector.pro
./tools/.pch
./tools/.pch/debug-shared
-./tools/qstringbuilder
-./tools/qstringbuilder/main.cpp
-./tools/qstringbuilder/Makefile
-./tools/qstringbuilder/qstringbuilder.pro
./tools/containers-sequential
./tools/containers-sequential/containers-sequential.pro
./tools/containers-sequential/main.cpp
./tools/containers-sequential/Makefile
-./tools/qstring
-./tools/qstring/generatelist.pl
-./tools/qstring/data.h
-./tools/qstring/qstring.pro
-./tools/qstring/main.cpp
-./tools/qstring/data.cpp
-./tools/qstring/Makefile
-./tools/qstring/utf-8.txt
-./tools/qstringlist
-./tools/qstringlist/qstringlist.pro
-./tools/qstringlist/main.cpp
-./tools/qstringlist/.gitignore
-./tools/qstringlist/Makefile
-./tools/qbytearray
-./tools/qbytearray/qbytearray.pro
-./tools/qbytearray/main.cpp
-./tools/qbytearray/Makefile
./tools/containers-associative
./tools/containers-associative/containers-associative.pro
./tools/containers-associative/main.cpp
diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
index c7173b5b8d..16a911c63a 100644
--- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h
+++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
@@ -32,7 +32,6 @@
#include <QtCore/qiterator.h>
#include <QtCore/qdebug.h>
#include <QtCore/qatomic.h>
-#include <QtCore/qalgorithms.h>
#include <QtCore/qlist.h>
#include <QtCore/private/qtools_p.h>
@@ -263,9 +262,9 @@ public:
//static QRawVector<T> fromList(const QList<T> &list);
static inline QRawVector<T> fromStdVector(const std::vector<T> &vector)
- { QRawVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
+ { QRawVector<T> tmp; std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
- { std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
+ { std::vector<T> tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
private:
T *allocate(int alloc);
@@ -568,7 +567,7 @@ typename QRawVector<T>::iterator QRawVector<T>::erase(iterator abegin, iterator
int l = int(aend - m_begin);
int n = l - f;
if (QTypeInfo<T>::isComplex) {
- qCopy(m_begin + l, m_begin + m_size, m_begin + f);
+ std::copy(m_begin + l, m_begin + m_size, m_begin + f);
T *i = m_begin + m_size;
T *b = m_begin + m_size - n;
while (i != b) {
diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro
index ca9c0a6f89..b4ee0520a6 100644
--- a/tests/benchmarks/corelib/tools/tools.pro
+++ b/tests/benchmarks/corelib/tools/tools.pro
@@ -2,21 +2,12 @@ TEMPLATE = subdirs
SUBDIRS = \
containers-associative \
containers-sequential \
- qbytearray \
qcontiguouscache \
qcryptographichash \
- qdatetime \
qlist \
- qlocale \
qmap \
qrect \
qringbuffer \
qstack \
- qstring \
- qstringbuilder \
- qstringlist \
- qtimezone \
qvector \
qalgorithms
-
-!*g++*: SUBDIRS -= qstring
diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
index 605df100ee..b8afb3bc05 100644
--- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
+++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
@@ -183,6 +183,7 @@ void tst_QImageConversion::convertRgb32_data()
QTest::newRow("rgb32 -> rgb30") << rgb32 << QImage::Format_RGB30;
QTest::newRow("rgb32 -> a2bgr30") << rgb32 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("rgb32 -> rgb888") << rgb32 << QImage::Format_RGB888;
+ QTest::newRow("rgb32 -> bgr888") << rgb32 << QImage::Format_BGR888;
QTest::newRow("rgb32 -> rgb666") << rgb32 << QImage::Format_RGB666;
QTest::newRow("rgb32 -> rgb555") << rgb32 << QImage::Format_RGB555;
QTest::newRow("rgb32 -> argb8565pm") << rgb32 << QImage::Format_ARGB8565_Premultiplied;
@@ -196,6 +197,7 @@ void tst_QImageConversion::convertRgb32_data()
QTest::newRow("argb32 -> rgb30") << argb32 << QImage::Format_RGB30;
QTest::newRow("argb32 -> a2bgr30") << argb32 << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("argb32 -> rgb888") << argb32 << QImage::Format_RGB888;
+ QTest::newRow("argb32 -> bgr888") << argb32 << QImage::Format_BGR888;
QTest::newRow("argb32 -> rgb666") << argb32 << QImage::Format_RGB666;
QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
@@ -212,6 +214,7 @@ void tst_QImageConversion::convertRgb32_data()
QTest::newRow("argb32pm -> rgb30") << argb32pm << QImage::Format_RGB30;
QTest::newRow("argb32pm -> a2bgr30") << argb32pm << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("argb32pm -> rgb888") << argb32pm << QImage::Format_RGB888;
+ QTest::newRow("argb32pm -> bgr888") << argb32pm << QImage::Format_BGR888;
QTest::newRow("argb32pm -> rgb666") << argb32pm << QImage::Format_RGB666;
QTest::newRow("argb32pm -> argb8565pm") << argb32pm << QImage::Format_ARGB8565_Premultiplied;
QTest::newRow("argb32pm -> argb4444pm") << argb32pm << QImage::Format_ARGB4444_Premultiplied;
@@ -242,6 +245,8 @@ void tst_QImageConversion::convertGeneric_data()
QImage rgb666 = rgb32.convertToFormat(QImage::Format_RGB666);
QImage argb4444 = argb32.convertToFormat(QImage::Format_ARGB4444_Premultiplied);
QImage rgba64pm = argb32.convertToFormat(QImage::Format_RGBA64_Premultiplied);
+ QImage rgb888 = rgb32.convertToFormat(QImage::Format_RGB888);
+ QImage bgr888 = rgb32.convertToFormat(QImage::Format_BGR888);
QTest::newRow("indexed8 -> rgb32") << i8 << QImage::Format_RGB32;
QTest::newRow("indexed8 -> argb32") << i8 << QImage::Format_ARGB32;
@@ -299,6 +304,20 @@ void tst_QImageConversion::convertGeneric_data()
QTest::newRow("rgba64pm -> rgb30") << rgba64pm << QImage::Format_RGB30;
QTest::newRow("rgba64pm -> a2bgr30") << rgba64pm << QImage::Format_A2BGR30_Premultiplied;
QTest::newRow("rgba64pm -> rgba64") << rgba64pm << QImage::Format_RGBA64;
+
+ QTest::newRow("rgb888 -> rgb32") << rgb888 << QImage::Format_RGB32;
+ QTest::newRow("rgb888 -> argb32") << rgb888 << QImage::Format_ARGB32;
+ QTest::newRow("rgb888 -> argb32pm") << rgb888 << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("rgb888 -> rgbx8888") << rgb888 << QImage::Format_RGBX8888;
+ QTest::newRow("rgb888 -> rgba8888pm") << rgb888 << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("rgb888 -> bgr888") << rgb888 << QImage::Format_BGR888;
+
+ QTest::newRow("bgr888 -> rgb32") << bgr888 << QImage::Format_RGB32;
+ QTest::newRow("bgr888 -> argb32") << bgr888 << QImage::Format_ARGB32;
+ QTest::newRow("bgr888 -> argb32pm") << bgr888 << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("bgr888 -> rgbx8888") << bgr888 << QImage::Format_RGBX8888;
+ QTest::newRow("bgr888 -> rgba8888pm") << bgr888 << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("bgr888 -> rgb888") << bgr888 << QImage::Format_RGB888;
}
void tst_QImageConversion::convertGeneric()
@@ -323,6 +342,8 @@ void tst_QImageConversion::convertGenericInplace_data()
QImage argb6666 = argb32.convertToFormat(QImage::Format_ARGB6666_Premultiplied);
QImage argb4444 = argb32.convertToFormat(QImage::Format_ARGB4444_Premultiplied);
QImage rgb16 = argb32.convertToFormat(QImage::Format_RGB16);
+ QImage rgb30 = argb32.convertToFormat(QImage::Format_RGB30);
+ QImage rgb888 = argb32.convertToFormat(QImage::Format_RGB888);
QTest::newRow("argb32 -> argb32pm -> argb32") << argb32 << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("argb32 -> rgb32 -> argb32") << argb32 << QImage::Format_RGB32;
@@ -349,6 +370,9 @@ void tst_QImageConversion::convertGenericInplace_data()
QTest::newRow("rgb16 -> rgb555 -> rgb16") << rgb16 << QImage::Format_RGB555;
QTest::newRow("rgb16 -> rgb444 -> rgb16") << rgb16 << QImage::Format_RGB444;
QTest::newRow("rgb16 -> argb4444pm -> rgb16") << rgb16 << QImage::Format_ARGB4444_Premultiplied;
+
+ QTest::newRow("rgb30 -> bgr30 -> rgb30") << rgb30 << QImage::Format_BGR30;
+ QTest::newRow("rgb888 -> bgr888 -> rgb888") << rgb888 << QImage::Format_BGR888;
}
void tst_QImageConversion::convertGenericInplace()
@@ -357,10 +381,10 @@ void tst_QImageConversion::convertGenericInplace()
QFETCH(QImage::Format, outputFormat);
QImage::Format inputFormat = inputImage.format();
- QImage tmpImage = qMove(inputImage);
+ QImage tmpImage = std::move(inputImage);
QBENCHMARK {
- tmpImage = (qMove(tmpImage).convertToFormat(outputFormat)).convertToFormat(inputFormat);
+ tmpImage = (std::move(tmpImage).convertToFormat(outputFormat)).convertToFormat(inputFormat);
}
}
diff --git a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro
index 29f7f6b16e..3454cf1474 100644
--- a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro
+++ b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro
@@ -8,3 +8,5 @@ SOURCES += tst_qimagereader.cpp
qtConfig(gif): DEFINES += QTEST_HAVE_GIF
qtConfig(jpeg): DEFINES += QTEST_HAVE_JPEG
+
+TESTDATA += images/*
diff --git a/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp b/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp
index d81d5bb01a..48e838148f 100644
--- a/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp
@@ -51,6 +51,7 @@ public:
virtual ~tst_QImageReader();
public slots:
+ void initTestCase();
void init();
void cleanup();
@@ -69,6 +70,7 @@ private slots:
private:
QList< QPair<QString, QByteArray> > images; // filename, format
+ QString prefix;
};
tst_QImageReader::tst_QImageReader()
@@ -102,6 +104,13 @@ tst_QImageReader::~tst_QImageReader()
{
}
+void tst_QImageReader::initTestCase()
+{
+ prefix = QFINDTESTDATA("images/");
+ if (prefix.isEmpty())
+ QFAIL("Can't find images directory!");
+}
+
void tst_QImageReader::init()
{
}
@@ -128,7 +137,7 @@ void tst_QImageReader::readImage()
QFETCH(QByteArray, format);
QBENCHMARK {
- QImageReader io("images/" + fileName, format);
+ QImageReader io(prefix + fileName, format);
QImage image = io.read();
QVERIFY(!image.isNull());
}
@@ -159,7 +168,7 @@ void tst_QImageReader::setScaledSize()
QFETCH(QByteArray, format);
QBENCHMARK {
- QImageReader reader("images/" + fileName, format);
+ QImageReader reader(prefix + fileName, format);
reader.setScaledSize(newSize);
QImage image = reader.read();
QCOMPARE(image.size(), newSize);
@@ -186,7 +195,7 @@ void tst_QImageReader::setClipRect()
QFETCH(QByteArray, format);
QBENCHMARK {
- QImageReader reader("images/" + fileName, format);
+ QImageReader reader(prefix + fileName, format);
reader.setClipRect(newRect);
QImage image = reader.read();
QCOMPARE(image.rect(), newRect);
@@ -205,7 +214,7 @@ void tst_QImageReader::setScaledClipRect()
QFETCH(QByteArray, format);
QBENCHMARK {
- QImageReader reader("images/" + fileName, format);
+ QImageReader reader(prefix + fileName, format);
reader.setScaledSize(QSize(300, 300));
reader.setScaledClipRect(newRect);
QImage image = reader.read();
diff --git a/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp
index d4be85b5ad..2ded426cdd 100644
--- a/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/benchmarks/gui/image/qpixmapcache/tst_qpixmapcache.cpp
@@ -106,7 +106,7 @@ void tst_QPixmapCache::find()
if (cacheType) {
QBENCHMARK {
for (int i = 0 ; i <= 10000 ; i++)
- QPixmapCache::find(QString::asprintf("my-key-%d", i), p);
+ QPixmapCache::find(QString::asprintf("my-key-%d", i), &p);
}
} else {
QBENCHMARK {
@@ -155,7 +155,7 @@ void tst_QPixmapCache::styleUseCaseComplexKey()
QPixmapCache::insert(QString::asprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200), p);
for (int i = 0 ; i <= 10000 ; i++)
- QPixmapCache::find(QString::asprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200), p);
+ QPixmapCache::find(QString::asprintf("%s-%d-%d-%d-%d-%d-%d", QString("my-progressbar-%1").arg(i).toLatin1().constData(), 5, 3, 0, 358, 100, 200), &p);
}
} else {
QHash<styleStruct, QPixmapCache::Key> hash;
diff --git a/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp b/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp
index d7a7f383ac..12e85d4842 100644
--- a/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp
+++ b/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp
@@ -167,9 +167,7 @@ void tst_QTransform::func##_data() \
{ \
QTest::addColumn<QTransform>("transform"); \
QMap<const char *, QTransform> x = generateTransforms(); \
- QMapIterator<const char *, QTransform> it(x); \
- while (it.hasNext()) { \
- it.next(); \
+ for (auto it = x.begin(), end = x.end(); it != end; ++it) { \
QTest::newRow(it.key()) << it.value(); \
} \
}
@@ -180,14 +178,10 @@ void tst_QTransform::func##_data() \
QTest::addColumn<QTransform>("x1"); \
QTest::addColumn<QTransform>("x2"); \
QMap<const char *, QTransform> x = generateTransforms(); \
- QMapIterator<const char *, QTransform> it(x); \
- while (it.hasNext()) { \
- it.next(); \
+ for (auto it = x.cbegin(), end = x.cend(); it != end; ++it) { \
const char *key1 = it.key(); \
QTransform x1 = it.value(); \
- QMapIterator<const char *, QTransform> it2(x); \
- while (it2.hasNext()) { \
- it2.next(); \
+ for (auto it2 = x.cbegin(), end = x.cend(); it2 != end; ++it2) { \
QTest::newRow(QString("%1 + %2").arg(key1).arg(it2.key()).toLatin1().constData()) \
<< x1 << it2.value(); \
} \
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index b2f4cbd7ba..c182ef7ebf 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -908,7 +908,7 @@ void tst_qnetworkreply::httpsRequestChain()
qint64 average = (elapsed / count);
- qSort(helper.timeList);
+ std::sort(helper.timeList.begin(), helper.timeList.end());
qint64 median = helper.timeList.at(5);
qDebug() << "Total:" << elapsed << " Average:" << average << " Median:" << median;
diff --git a/tests/benchmarks/opengl/main.cpp b/tests/benchmarks/opengl/main.cpp
index 5008f1592b..0886c0e55b 100644
--- a/tests/benchmarks/opengl/main.cpp
+++ b/tests/benchmarks/opengl/main.cpp
@@ -76,7 +76,6 @@ void OpenGLBench::initTestCase()
QPainter p(pb);
p.setRenderHint(QPainter::Antialiasing);
- p.setRenderHint(QPainter::HighQualityAntialiasing);
p.drawImage(0, 0, QImage(256, 256, QImage::Format_ARGB32_Premultiplied));
}
@@ -120,7 +119,6 @@ void OpenGLBench::imageDrawing()
QPainter p(pb);
p.setRenderHint(QPainter::SmoothPixmapTransform, smoothPixmapTransform);
p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing);
- p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing);
QBENCHMARK {
if (pixmap) {
@@ -182,7 +180,6 @@ void OpenGLBench::pathDrawing()
dummy.addRect(-1, -1, 2, 2);
QPainter p(pb);
p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing);
- p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing);
p.translate(pb->width() / 2, pb->height() / 2);
p.rotate(30);
p.drawPath(dummy);
@@ -196,7 +193,6 @@ void OpenGLBench::pathDrawing()
QBENCHMARK {
p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing);
- p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing);
p.rotate(0.01);
p.drawPath(path);
@@ -227,7 +223,6 @@ void OpenGLBench::startupCost()
QGLPixelBuffer buffer(512, 512);
QPainter p(&buffer);
p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing);
- p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing);
p.translate(buffer.width() / 2, buffer.height() / 2);
p.drawPath(path);
diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp
index c8ccb60dbb..8f7736010d 100644
--- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp
+++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp
@@ -270,7 +270,6 @@ void MainView::construct()
// Turn off automatic background
setAttribute(Qt::WA_OpaquePaintEvent);
- setAttribute(Qt::WA_NoBackground);
setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(false);
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index b15aad04cd..e0c5a7f683 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -60,7 +60,7 @@ public:
{
Q_UNUSED(option);
Q_UNUSED(widget);
- painter->drawRoundRect(rect());
+ painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
painter->drawLine(rect().topLeft(), rect().bottomRight());
painter->drawLine(rect().bottomLeft(), rect().topRight());
}
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index 5c97d7f738..caf5455a80 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -53,7 +53,7 @@ public:
{
Q_UNUSED(option);
Q_UNUSED(widget);
- painter->drawRoundRect(rect());
+ painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
painter->drawLine(rect().topLeft(), rect().bottomRight());
painter->drawLine(rect().bottomLeft(), rect().topRight());
}
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp
index 57ab62b1c3..2277ae0f14 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp
@@ -38,7 +38,7 @@ Chip::Chip(const QColor &color, int x, int y)
setZValue((x + y) % 2);
setFlags(ItemIsSelectable | ItemIsMovable);
- setAcceptsHoverEvents(true);
+ setAcceptHoverEvents(true);
}
QRectF Chip::boundingRect() const
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
index de4e9e5ad7..6e0ac445a6 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
@@ -30,12 +30,7 @@
#include <QtGui>
-#if 0 // Used to be included in Qt4 for Q_WS_WIN
-#define CALLGRIND_START_INSTRUMENTATION {}
-#define CALLGRIND_STOP_INSTRUMENTATION {}
-#else
#include "valgrind/callgrind.h"
-#endif
#ifndef QT_NO_OPENGL
#include <QtOpenGL>
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
index e0cc0f8eb4..140278b8f6 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
@@ -27,16 +27,7 @@
****************************************************************************/
#include <QtGui>
-#if 0 // Used to be included in Qt4 for Q_WS_WIN
-#define CALLGRIND_START_INSTRUMENTATION {}
-#define CALLGRIND_STOP_INSTRUMENTATION {}
-#else
#include "valgrind/callgrind.h"
-#endif
-
-#if 0 // Used to be included in Qt4 for Q_WS_X11
-extern void qt_x11_wait_for_window_manager(QWidget *);
-#endif
class View : public QGraphicsView
{
@@ -89,9 +80,6 @@ int main(int argc, char *argv[])
View view(&scene, item);
view.resize(300, 300);
view.show();
-#if 0 // Used to be included in Qt4 for Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
return app.exec();
}
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
index 1fbb229cd8..566d16ca51 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
@@ -27,12 +27,7 @@
****************************************************************************/
#include <QtGui>
-#if 0 // Used to be included in Qt4 for Q_WS_WIN
-#define CALLGRIND_START_INSTRUMENTATION {}
-#define CALLGRIND_STOP_INSTRUMENTATION {}
-#else
#include "valgrind/callgrind.h"
-#endif
class ItemMover : public QObject
{
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.cpp
index cf82282bfe..21eb622f15 100644
--- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.cpp
+++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.cpp
@@ -57,9 +57,9 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
{
Q_UNUSED(widget);
- QColor fillColor = (option->state & QStyle::State_Selected) ? color.dark(150) : color;
+ QColor fillColor = (option->state & QStyle::State_Selected) ? color.darker(150) : color;
if (option->state & QStyle::State_MouseOver)
- fillColor = fillColor.light(125);
+ fillColor = fillColor.lighter(125);
if (option->levelOfDetail < 0.2) {
if (option->levelOfDetail < 0.125) {
@@ -82,7 +82,7 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
pen.setWidth(width);
QBrush b = painter->brush();
- painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100)));
+ painter->setBrush(QBrush(fillColor.darker(option->state & QStyle::State_Sunken ? 120 : 100)));
painter->drawRect(QRect(14, 14, 79, 39));
painter->setBrush(b);