summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib')
-rw-r--r--tests/benchmarks/corelib/CMakeLists.txt4
-rw-r--r--tests/benchmarks/corelib/io/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp69
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt2
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp4
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h2
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp80
-rw-r--r--tests/benchmarks/corelib/io/qfile/CMakeLists.txt8
-rw-r--r--tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp14
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qprocess/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp6
-rw-r--r--tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qurl/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp2
-rw-r--r--tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp18
-rw-r--r--tests/benchmarks/corelib/json/CMakeLists.txt8
-rw-r--r--tests/benchmarks/corelib/json/tst_bench_qtjson.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/kernel/events/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp3
-rw-r--r--tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp28
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/object.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/object.h2
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qproperty/propertytester.h2
-rw-r--r--tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt8
-rw-r--r--tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp6
-rw-r--r--tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt12
-rw-r--r--tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp2
-rw-r--r--tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp2
-rw-r--r--tests/benchmarks/corelib/mimetypes/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/mimetypes/qmimedatabase/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp37
-rw-r--r--tests/benchmarks/corelib/plugin/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/plugin/quuid/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/plugin/quuid/tst_bench_quuid.cpp2
-rw-r--r--tests/benchmarks/corelib/serialization/CMakeLists.txt4
-rw-r--r--tests/benchmarks/corelib/serialization/qcborvalue/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp95
-rw-r--r--tests/benchmarks/corelib/text/CMakeLists.txt4
-rw-r--r--tests/benchmarks/corelib/text/qbytearray/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp37
-rw-r--r--tests/benchmarks/corelib/text/qchar/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qchar/tst_bench_qchar.cpp2
-rw-r--r--tests/benchmarks/corelib/text/qlocale/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qlocale/tst_bench_qlocale.cpp223
-rw-r--r--tests/benchmarks/corelib/text/qregularexpression/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qregularexpression/tst_bench_qregularexpression.cpp2
-rw-r--r--tests/benchmarks/corelib/text/qstring/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qstring/tst_bench_qstring.cpp229
-rw-r--r--tests/benchmarks/corelib/text/qstringbuilder/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qstringbuilder/tst_bench_qstringbuilder.cpp2
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/tst_bench_qstringlist.cpp58
-rw-r--r--tests/benchmarks/corelib/text/qstringtokenizer/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/text/qstringtokenizer/tst_bench_qstringtokenizer.cpp2
-rw-r--r--tests/benchmarks/corelib/text/qutf8stringview/CMakeLists.txt14
-rw-r--r--tests/benchmarks/corelib/text/qutf8stringview/tst_bench_qutf8stringview.cpp263
-rw-r--r--tests/benchmarks/corelib/thread/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/thread/qfuture/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp20
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp46
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp2
-rw-r--r--tests/benchmarks/corelib/thread/qthreadpool/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/thread/qthreadpool/tst_bench_qthreadpool.cpp2
-rw-r--r--tests/benchmarks/corelib/thread/qthreadstorage/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/thread/qthreadstorage/tst_bench_qthreadstorage.cpp3
-rw-r--r--tests/benchmarks/corelib/thread/qwaitcondition/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp2
-rw-r--r--tests/benchmarks/corelib/time/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/time/qdate/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp29
-rw-r--r--tests/benchmarks/corelib/time/qdatetime/CMakeLists.txt6
-rw-r--r--tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp63
-rw-r--r--tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp48
-rw-r--r--tests/benchmarks/corelib/tools/CMakeLists.txt3
-rw-r--r--tests/benchmarks/corelib/tools/containers-associative/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/containers-associative/tst_bench_containers_associative.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/containers-sequential/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/containers-sequential/tst_bench_containers_sequential.cpp6
-rw-r--r--tests/benchmarks/corelib/tools/qcontiguouscache/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qcontiguouscache/tst_bench_qcontiguouscache.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qcryptographichash/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp190
-rw-r--r--tests/benchmarks/corelib/tools/qhash/CMakeLists.txt7
-rw-r--r--tests/benchmarks/corelib/tools/qhash/outofline.cpp18
-rw-r--r--tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp50
-rw-r--r--tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.h20
-rw-r--r--tests/benchmarks/corelib/tools/qlist/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qlist/tst_bench_qlist.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qmap/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qrect/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qrect/tst_bench_qrect.cpp4
-rw-r--r--tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qset/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qset/tst_bench_qset.cpp76
-rw-r--r--tests/benchmarks/corelib/tools/qsharedpointer/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qstack/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qstack/tst_bench_qstack.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qvector/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/tools/qvector/outofline.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qrawvector.h2
-rw-r--r--tests/benchmarks/corelib/tools/qvector/tst_bench_qvector.cpp2
135 files changed, 1778 insertions, 393 deletions
diff --git a/tests/benchmarks/corelib/CMakeLists.txt b/tests/benchmarks/corelib/CMakeLists.txt
index ff30862180..855e7ee2fa 100644
--- a/tests/benchmarks/corelib/CMakeLists.txt
+++ b/tests/benchmarks/corelib/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from corelib.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(io)
add_subdirectory(itemmodels)
@@ -10,3 +11,4 @@ add_subdirectory(thread)
add_subdirectory(time)
add_subdirectory(tools)
add_subdirectory(plugin)
+add_subdirectory(serialization)
diff --git a/tests/benchmarks/corelib/io/CMakeLists.txt b/tests/benchmarks/corelib/io/CMakeLists.txt
index 8d4b556abc..e9bf2292c0 100644
--- a/tests/benchmarks/corelib/io/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
add_subdirectory(qdir)
add_subdirectory(qdiriterator)
add_subdirectory(qfile)
diff --git a/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt b/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt
index d1feaa5f18..142c13aceb 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qdir_10000 Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qdir_10000
SOURCES
tst_bench_qdir_10000.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
index 276fe230d7..a53742b536 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
+++ b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
@@ -1,5 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QTest>
#include <QDirIterator>
@@ -32,24 +34,14 @@ public slots:
}
void cleanupTestCase()
{
- {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Unsorted);
- testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
- foreach (const QString &filename, testdir.entryList()) {
- testdir.remove(filename);
- }
- }
- const QDir temp = QDir(QDir::tempPath());
- temp.rmdir(QLatin1String("test_speed"));
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ QVERIFY(testdir.removeRecursively());
}
private slots:
- void baseline() {}
-
void sizeSpeed()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QFileInfoList fileInfoList = testdir.entryInfoList(QDir::Files, QDir::Unsorted);
foreach (const QFileInfo &fileInfo, fileInfoList) {
fileInfo.isDir();
@@ -59,8 +51,8 @@ private slots:
}
void sizeSpeedIterator()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QDirIterator dit(testdir.path(), QDir::Files);
while (dit.hasNext()) {
const auto fi = dit.nextFileInfo();
@@ -72,8 +64,8 @@ private slots:
void sizeSpeedWithoutFilter()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QFileInfoList fileInfoList = testdir.entryInfoList(QDir::NoFilter, QDir::Unsorted);
foreach (const QFileInfo &fileInfo, fileInfoList) {
fileInfo.size();
@@ -82,8 +74,8 @@ private slots:
}
void sizeSpeedWithoutFilterIterator()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QDirIterator dit(testdir.path());
while (dit.hasNext()) {
const auto fi = dit.nextFileInfo();
@@ -95,9 +87,9 @@ private slots:
void sizeSpeedWithoutFileInfoList()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Unsorted);
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ testdir.setSorting(QDir::Unsorted);
QStringList fileList = testdir.entryList(QDir::NoFilter, QDir::Unsorted);
foreach (const QString &filename, fileList) {
QFileInfo fileInfo(filename);
@@ -108,10 +100,10 @@ private slots:
void iDontWantAnyStat()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Unsorted);
- testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ testdir.setSorting(QDir::Unsorted);
+ testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
QStringList fileList = testdir.entryList(QDir::NoFilter, QDir::Unsorted);
foreach (const QString &filename, fileList) {
Q_UNUSED(filename);
@@ -130,10 +122,10 @@ private slots:
void sorted_byTime()
{
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Time);
- testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ testdir.setSorting(QDir::Time);
+ testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
QStringList fileList = testdir.entryList(QDir::NoFilter, QDir::Time);
foreach (const QString &filename, fileList) {
Q_UNUSED(filename);
@@ -141,6 +133,15 @@ private slots:
}
}
+ void sorted_byName()
+ {
+ QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
+ [[maybe_unused]] auto r = testdir.entryInfoList(QDir::NoFilter, QDir::Name);
+ }
+ }
+
void sizeSpeedWithoutFilterLowLevel()
{
QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
@@ -150,22 +151,22 @@ private slots:
wcscpy(appendedPath, dirpath);
wcscat(appendedPath, L"\\*");
- WIN32_FIND_DATA fd;
- HANDLE hSearch = FindFirstFileW(appendedPath, &fd);
- QVERIFY(hSearch != INVALID_HANDLE_VALUE);
-
QBENCHMARK {
+ WIN32_FIND_DATA fd;
+ HANDLE hSearch = FindFirstFileW(appendedPath, &fd);
+ QVERIFY(hSearch != INVALID_HANDLE_VALUE);
+
do {
} while (FindNextFile(hSearch, &fd));
+ FindClose(hSearch);
}
- FindClose(hSearch);
#else
- DIR *dir = opendir(qPrintable(testdir.absolutePath()));
- QVERIFY(dir);
-
QVERIFY(!chdir(qPrintable(testdir.absolutePath())));
QBENCHMARK {
+ DIR *dir = opendir(qPrintable(testdir.absolutePath()));
+ QVERIFY(dir);
+
struct dirent *item = readdir(dir);
while (item) {
char *fileName = item->d_name;
@@ -175,8 +176,8 @@ private slots:
item = readdir(dir);
}
+ closedir(dir);
}
- closedir(dir);
#endif
}
};
diff --git a/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt b/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt
index ee5f7eabc1..6f1a208fe0 100644
--- a/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt
+++ b/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt
@@ -7983,8 +7983,6 @@
qeventloop.cpp
qeventloop.h
qfunctions_p.h
- qfunctions_vxworks.cpp
- qfunctions_vxworks.h
qfunctions_wince.cpp
qfunctions_wince.h
qguard_p.h
diff --git a/tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt b/tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt
index 32dea04edc..f60c108480 100644
--- a/tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qdir_tree Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qdir_tree
SOURCES
tst_bench_qdir_tree.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp
index 95ab82b90a..4f122c876c 100644
--- a/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp
+++ b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QTest>
@@ -69,7 +69,7 @@ private slots:
stack.push(line);
line = prefix;
- for (const QByteArray &pathElement : qAsConst(stack))
+ for (const QByteArray &pathElement : std::as_const(stack))
line += pathElement;
if (line.endsWith('/'))
diff --git a/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt b/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt
index f250a9627a..6a4579d35d 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qdiriterator Binary:
#####################################################################
@@ -6,7 +9,7 @@ qt_internal_add_benchmark(tst_bench_qdiriterator
SOURCES
tst_bench_qdiriterator.cpp
qfilesystemiterator.cpp qfilesystemiterator.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
index d13017f108..16b64cf362 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
/*!
\since 4.5
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
index 5b39d7326c..479ce7b392 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QFILESYSTEMITERATOR_H
#define QFILESYSTEMITERATOR_H
diff --git a/tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp
index c1826e99e4..66448bf838 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp
@@ -1,7 +1,8 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QDirIterator>
+#include <QDirListing>
#include <QString>
#include <qplatformdefs.h>
@@ -23,16 +24,30 @@
#include <filesystem>
#endif
+using namespace Qt::StringLiterals;
+
+constexpr bool forceStat = false;
+
class tst_QDirIterator : public QObject
{
Q_OBJECT
void data();
+
+ const QDir::Filters dirFilters =
+ // QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot
+ QDir::AllEntries | QDir::Hidden
+ //QDir::Files | QDir::NoDotAndDotDot,
+ // QDir::Files,
+ ;
+
private slots:
void posix();
void posix_data() { data(); }
void diriterator();
void diriterator_data() { data(); }
+ void dirlisting();
+ void dirlisting_data() { data(); }
void fsiterator();
void fsiterator_data() { data(); }
void stdRecursiveDirectoryIterator();
@@ -118,9 +133,20 @@ static int posix_helper(const char *dirpath)
QByteArray ba = dirpath;
ba += '/';
ba += entry->d_name;
+ bool isDir = false;
+#if defined(_DIRENT_HAVE_D_TYPE) || defined(Q_OS_BSD4)
+ isDir = entry->d_type == DT_DIR;
+ if (forceStat) {
+ QT_STATBUF st;
+ QT_LSTAT(ba.constData(), &st);
+ }
+#else // d_type not available >>> must stat() to see if it's a dir
QT_STATBUF st;
QT_LSTAT(ba.constData(), &st);
- if (S_ISDIR(st.st_mode))
+ isDir = S_ISDIR(st.st_mode);
+#endif
+
+ if (isDir)
count += posix_helper(ba.constData());
}
@@ -157,14 +183,12 @@ void tst_QDirIterator::diriterator()
QBENCHMARK {
int c = 0;
- QDirIterator dir(dirpath,
- //QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot,
- //QDir::AllEntries | QDir::Hidden,
- QDir::Files,
- QDirIterator::Subdirectories);
+ QDirIterator dir(dirpath, dirFilters, QDirIterator::Subdirectories);
while (dir.hasNext()) {
const auto fi = dir.nextFileInfo();
+ if (forceStat)
+ fi.size();
//printf("%s\n", qPrintable(dir.fileName()));
0 && printf("%d %s\n",
fi.isDir(),
@@ -178,6 +202,28 @@ void tst_QDirIterator::diriterator()
qDebug() << count;
}
+void tst_QDirIterator::dirlisting()
+{
+ QFETCH(QByteArray, dirpath);
+
+ int count = 0;
+
+ QBENCHMARK {
+ int c = 0;
+
+ QDirListing dir(dirpath, dirFilters, QDirListing::IteratorFlag::Recursive);
+
+ for (const auto &dirEntry : dir) {
+ const auto path = dirEntry.filePath();
+ if (forceStat)
+ dirEntry.size();
+ ++c;
+ }
+ count = c;
+ }
+ qDebug() << count;
+}
+
void tst_QDirIterator::fsiterator()
{
QFETCH(QByteArray, dirpath);
@@ -189,14 +235,12 @@ void tst_QDirIterator::fsiterator()
int c = 0;
dump && printf("\n\n\n\n");
- QDirIteratorTest::QFileSystemIterator dir(dirpath,
- //QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot,
- //QDir::AllEntries | QDir::Hidden,
- //QDir::Files | QDir::NoDotAndDotDot,
- QDir::Files,
- QDirIteratorTest::QFileSystemIterator::Subdirectories);
+ QDirIteratorTest::QFileSystemIterator dir(
+ dirpath, dirFilters, QDirIteratorTest::QFileSystemIterator::Subdirectories);
for (; !dir.atEnd(); dir.next()) {
+ if (forceStat)
+ dir.fileInfo().size();
dump && printf("%d %s\n",
dir.fileInfo().isDir(),
//qPrintable(dir.fileInfo().absoluteFilePath()),
@@ -217,10 +261,16 @@ void tst_QDirIterator::stdRecursiveDirectoryIterator()
int count = 0;
+ namespace fs = std::filesystem;
+ std::error_code ec;
+
+ // Note that fs::recursive_directory_iterator may be calling stat() internally,
+ // that depends on the implementation. So the benchmark times might "seem" higher
+ // than the other methods in this source file.
QBENCHMARK {
int c = 0;
- for (auto obj : std::filesystem::recursive_directory_iterator(dirpath.data())) {
- if (obj.is_directory())
+ for (const auto &dirEntry : fs::recursive_directory_iterator(dirpath.data(), ec)) {
+ if (dirEntry.is_directory())
continue;
c++;
}
diff --git a/tests/benchmarks/corelib/io/qfile/CMakeLists.txt b/tests/benchmarks/corelib/io/qfile/CMakeLists.txt
index ed14a31780..0cd6b5fb16 100644
--- a/tests/benchmarks/corelib/io/qfile/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qfile/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qfile.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qfile Binary:
@@ -7,14 +8,11 @@
qt_internal_add_benchmark(tst_bench_qfile
SOURCES
tst_bench_qfile.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
-#### Keys ignored in scope 1:.:.:qfile.pro:<TRUE>:
-# TEMPLATE = "app"
-
## Scopes:
#####################################################################
diff --git a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
index ea25a3fa98..b805726f5f 100644
--- a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
+++ b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QTemporaryFile>
@@ -508,13 +508,13 @@ void tst_qfile::readSmallFiles()
}
QBENCHMARK {
- for (QFile *const file : qAsConst(fileList)) {
+ for (QFile *const file : std::as_const(fileList)) {
while (!file->atEnd())
file->read(buffer, blockSize);
}
}
- for (QFile *const file : qAsConst(fileList)) {
+ for (QFile *const file : std::as_const(fileList)) {
file->close();
delete file;
}
@@ -530,11 +530,11 @@ void tst_qfile::readSmallFiles()
}
QBENCHMARK {
- for (QFSFileEngine *const fse : qAsConst(fileList))
+ for (QFSFileEngine *const fse : std::as_const(fileList))
while (fse->read(buffer, blockSize)) {}
}
- for (QFSFileEngine *const fse : qAsConst(fileList)) {
+ for (QFSFileEngine *const fse : std::as_const(fileList)) {
fse->close();
delete fse;
}
@@ -547,14 +547,14 @@ void tst_qfile::readSmallFiles()
fileList.append(::fopen(QFile::encodeName(tempDir.filePath(file)).constData(), "rb"));
QBENCHMARK {
- for (FILE *const cfile : qAsConst(fileList)) {
+ for (FILE *const cfile : std::as_const(fileList)) {
while (!feof(cfile))
[[maybe_unused]] auto f = ::fread(buffer, blockSize, 1, cfile);
::fseek(cfile, 0, SEEK_SET);
}
}
- for (FILE *const cfile : qAsConst(fileList))
+ for (FILE *const cfile : std::as_const(fileList))
::fclose(cfile);
}
break;
diff --git a/tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt b/tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt
index 8933b30cf3..84a667ca7d 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qfileinfo Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qfileinfo
SOURCES
tst_bench_qfileinfo.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp b/tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp
index 4ef2cdad9c..2c626dde70 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp
+++ b/tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <qtest.h>
#include <QTest>
diff --git a/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt b/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt
index ab8abc8788..133a9a1ac3 100644
--- a/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qiodevice Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qiodevice
SOURCES
tst_bench_qiodevice.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp b/tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp
index b90fd4fbc5..cae90631ee 100644
--- a/tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp
+++ b/tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
#include <QFile>
diff --git a/tests/benchmarks/corelib/io/qprocess/CMakeLists.txt b/tests/benchmarks/corelib/io/qprocess/CMakeLists.txt
index d599539142..3f3ffd3d70 100644
--- a/tests/benchmarks/corelib/io/qprocess/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qprocess/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qprocess.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(testProcessLoopback)
add_subdirectory(test)
diff --git a/tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt b/tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt
index b08034e71d..c8837d3d65 100644
--- a/tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qprocess Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qprocess
SOURCES
../tst_bench_qprocess.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt
index a55a1e113a..cd486bd9cc 100644
--- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## testProcessLoopback Binary:
#####################################################################
diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp
index be1bf53a35..1f47f6b0f1 100644
--- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp
+++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <stdio.h>
diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
index a1abeca12a..9cf87a6653 100644
--- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
+++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QSignalSpy>
@@ -43,9 +43,9 @@ void tst_QProcess::echoTest_performance()
while (stopWatch.elapsed() < 2000) {
process.write(array);
while (process.bytesToWrite() > 0) {
- int readCount = readyReadSpy.count();
+ int readCount = readyReadSpy.size();
QVERIFY(process.waitForBytesWritten(5000));
- if (readyReadSpy.count() == readCount)
+ if (readyReadSpy.size() == readCount)
QVERIFY(process.waitForReadyRead(5000));
}
diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt b/tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
index 5342cf8912..a2a33a0dce 100644
--- a/tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qtemporaryfile Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qtemporaryfile
SOURCES
tst_bench_qtemporaryfile.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp b/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp
index fe7a8be79e..c72b525827 100644
--- a/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp
+++ b/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
#include <QFile>
diff --git a/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt b/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt
index b54610ad74..5e39b2fd90 100644
--- a/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qtextstream Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qtextstream
SOURCES
tst_bench_qtextstream.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp b/tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp
index 3d281c5615..74552b85cf 100644
--- a/tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp
+++ b/tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2014 David Faure <david.faure@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
diff --git a/tests/benchmarks/corelib/io/qurl/CMakeLists.txt b/tests/benchmarks/corelib/io/qurl/CMakeLists.txt
index e9c155ad3f..fc8d48450d 100644
--- a/tests/benchmarks/corelib/io/qurl/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qurl/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_qurl Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qurl
SOURCES
tst_bench_qurl.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp b/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp
index b0e0941001..87c4f51816 100644
--- a/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp
+++ b/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qurl.h>
#include <qtest.h>
diff --git a/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/CMakeLists.txt b/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/CMakeLists.txt
index 4ae255bbb4..f6f45fa1f4 100644
--- a/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/CMakeLists.txt
+++ b/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/CMakeLists.txt
@@ -1,6 +1,9 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_benchmark(tst_bench_qsortfilterproxymodel
SOURCES
tst_bench_qsortfilterproxymodel.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp b/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp
index f6a1a01085..0411972ce3 100644
--- a/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp
+++ b/tests/benchmarks/corelib/itemmodels/qsortfilterproxymodel/tst_bench_qsortfilterproxymodel.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 Igor Kushnir <igorkuo@gmail.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QSortFilterProxyModel>
#include <QString>
@@ -31,6 +31,7 @@ class tst_QSortFilterProxyModel : public QObject
private slots:
void clearFilter_data();
void clearFilter();
+ void setSourceModel();
private:
QStringList m_numberList; ///< Cache the strings for efficiency.
@@ -72,7 +73,7 @@ void tst_QSortFilterProxyModel::clearFilter()
{
QFETCH(const int, itemCount);
resizeNumberList(m_numberList, itemCount);
- QStringListModel model(qAsConst(m_numberList));
+ QStringListModel model(std::as_const(m_numberList));
QCOMPARE(model.rowCount(), itemCount);
QSortFilterProxyModel proxy;
@@ -93,6 +94,19 @@ void tst_QSortFilterProxyModel::clearFilter()
QCOMPARE(proxy.rowCount(), itemCount);
}
+void tst_QSortFilterProxyModel::setSourceModel()
+{
+ QStringListModel model1;
+ QStringListModel model2;
+
+ QSortFilterProxyModel proxy;
+
+ QBENCHMARK {
+ proxy.setSourceModel(&model1);
+ proxy.setSourceModel(&model2);
+ }
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_bench_qsortfilterproxymodel.moc"
diff --git a/tests/benchmarks/corelib/json/CMakeLists.txt b/tests/benchmarks/corelib/json/CMakeLists.txt
index 657a268741..f4feb1ebdb 100644
--- a/tests/benchmarks/corelib/json/CMakeLists.txt
+++ b/tests/benchmarks/corelib/json/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from json.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qtjson Binary:
@@ -7,9 +8,6 @@
qt_internal_add_benchmark(tst_bench_qtjson
SOURCES
tst_bench_qtjson.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:json.pro:<TRUE>:
-# TESTDATA = "numbers.json" "test.json"
diff --git a/tests/benchmarks/corelib/json/tst_bench_qtjson.cpp b/tests/benchmarks/corelib/json/tst_bench_qtjson.cpp
index 199bef8595..2202b9a576 100644
--- a/tests/benchmarks/corelib/json/tst_bench_qtjson.cpp
+++ b/tests/benchmarks/corelib/json/tst_bench_qtjson.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QVariantMap>
diff --git a/tests/benchmarks/corelib/kernel/CMakeLists.txt b/tests/benchmarks/corelib/kernel/CMakeLists.txt
index 07f6ac557e..137ef37298 100644
--- a/tests/benchmarks/corelib/kernel/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from kernel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(events)
add_subdirectory(qmetatype)
diff --git a/tests/benchmarks/corelib/kernel/events/CMakeLists.txt b/tests/benchmarks/corelib/kernel/events/CMakeLists.txt
index b5440891ee..ba175fd3a0 100644
--- a/tests/benchmarks/corelib/kernel/events/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/events/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_events Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_events
SOURCES
tst_bench_events.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp b/tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp
index 0b310afb94..17eb838af2 100644
--- a/tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp
+++ b/tests/benchmarks/corelib/kernel/events/tst_bench_events.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <qtest.h>
@@ -88,6 +88,7 @@ void EventsBench::noEvent()
QBENCHMARK {
val += tst.foo(1);
}
+ QVERIFY(val > 0);
}
void EventsBench::sendEvent_data()
diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt
index 0872bccf60..1a553199d3 100644
--- a/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qcoreapplication/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qcoreapplication Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qcoreapplication
SOURCES
tst_bench_qcoreapplication.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp b/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp
index 044acee366..d2ff489784 100644
--- a/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp
+++ b/tests/benchmarks/corelib/kernel/qcoreapplication/tst_bench_qcoreapplication.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2011 Robin Burchell <robin+qt@viroteck.net>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <qtest.h>
#include <qcoreapplication.h>
@@ -10,6 +10,9 @@ Q_OBJECT
private slots:
void event_posting_benchmark_data();
void event_posting_benchmark();
+
+ void event_posting_multiple_objects_benchmark_data();
+ void event_posting_multiple_objects_benchmark();
};
void tst_QCoreApplication::event_posting_benchmark_data()
@@ -39,6 +42,29 @@ void tst_QCoreApplication::event_posting_benchmark()
}
}
+void tst_QCoreApplication::event_posting_multiple_objects_benchmark_data()
+{
+ event_posting_benchmark_data();
+}
+
+void tst_QCoreApplication::event_posting_multiple_objects_benchmark()
+{
+ QFETCH(int, size);
+
+ QObject objects[15]; // The size of the array has not been chosen through any meaningful means
+
+ QRandomGenerator gen;
+
+ // benchmark posting & sending events
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i) {
+ QCoreApplication::postEvent(&objects[gen.bounded(0, int(std::size(objects)))],
+ new QTimerEvent(i % 10));
+ }
+ QCoreApplication::sendPostedEvents();
+ }
+}
+
QTEST_MAIN(tst_QCoreApplication)
#include "tst_bench_qcoreapplication.moc"
diff --git a/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt
index 5d7de3704e..78bc30ea73 100644
--- a/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qmetaenum/CMakeLists.txt
@@ -1,7 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_benchmark(tst_bench_qmetaenum
SOURCES
tst_bench_qmetaenum.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp b/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp
index 3ebbe176d8..1a88c49993 100644
--- a/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp
+++ b/tests/benchmarks/corelib/kernel/qmetaenum/tst_bench_qmetaenum.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QMetaEnum>
#include <QTest>
diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt
index 2afd390439..9e17608c57 100644
--- a/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qmetaobject/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qmetaobject Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qmetaobject
SOURCES
tst_bench_qmetaobject.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Test
Qt::Widgets
diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp
index f539ec2692..6b02fb4ba4 100644
--- a/tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp
+++ b/tests/benchmarks/corelib/kernel/qmetaobject/tst_bench_qmetaobject.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <QtWidgets/QTreeView>
#include <qtest.h>
diff --git a/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt
index 8fd20ee111..f24a29d144 100644
--- a/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qmetatype/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qmetatype Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qmetatype
SOURCES
tst_bench_qmetatype.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp
index 95e7bc5dfd..94adfa4a8c 100644
--- a/tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp
+++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_bench_qmetatype.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtest.h>
#include <QtCore/qmetatype.h>
diff --git a/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt
index fb13e8a59e..15b71f0d60 100644
--- a/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qobject/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qobject Binary:
#####################################################################
@@ -6,7 +9,7 @@ qt_internal_add_benchmark(tst_bench_qobject
SOURCES
tst_bench_qobject.cpp
object.cpp object.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Test
Qt::Widgets
diff --git a/tests/benchmarks/corelib/kernel/qobject/object.cpp b/tests/benchmarks/corelib/kernel/qobject/object.cpp
index 049a1a1107..9e0fba2e98 100644
--- a/tests/benchmarks/corelib/kernel/qobject/object.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/object.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "object.h"
void Object::emitSignal0()
diff --git a/tests/benchmarks/corelib/kernel/qobject/object.h b/tests/benchmarks/corelib/kernel/qobject/object.h
index 2f8bf7ca9f..72705f7f34 100644
--- a/tests/benchmarks/corelib/kernel/qobject/object.h
+++ b/tests/benchmarks/corelib/kernel/qobject/object.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef OBJECT_H
#define OBJECT_H
diff --git a/tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp b/tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp
index f3b3fc098a..99c15f6317 100644
--- a/tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/tst_bench_qobject.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <QtWidgets/QTreeView>
#include <qtest.h>
diff --git a/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt
index 42345e6492..1a26f28f05 100644
--- a/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qproperty/CMakeLists.txt
@@ -1,8 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_benchmark(tst_bench_qproperty
SOURCES
tst_bench_qproperty.cpp
propertytester.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/qproperty/propertytester.h b/tests/benchmarks/corelib/kernel/qproperty/propertytester.h
index f913395af6..a89d51c286 100644
--- a/tests/benchmarks/corelib/kernel/qproperty/propertytester.h
+++ b/tests/benchmarks/corelib/kernel/qproperty/propertytester.h
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PROPERTYTESTER_H
#define PROPERTYTESTER_H
diff --git a/tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp b/tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp
index 2d57c4c51e..c91ca1ea11 100644
--- a/tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp
+++ b/tests/benchmarks/corelib/kernel/qproperty/tst_bench_qproperty.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QScopedPointer>
#include <QProperty>
diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt
index 5ba14e43a2..22e04d98a2 100644
--- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qtimer_vs_qmetaobject.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## qtimer_vs_qmetaobject Binary:
@@ -9,9 +10,6 @@ qt_internal_add_benchmark(qtimer_vs_qmetaobject
tst_qtimer_vs_qmetaobject.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qtimer_vs_qmetaobject.pro:<TRUE>:
-# TEMPLATE = "app"
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 d36ea17756..d0b3e21772 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
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#include <QTest>
@@ -101,13 +101,9 @@ void qtimer_vs_qmetaobject::bench_data()
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/kernel/qvariant/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt
index 83e7269ff0..07978956b1 100644
--- a/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qvariant/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qvariant Binary:
#####################################################################
@@ -5,15 +8,14 @@
qt_internal_add_benchmark(tst_bench_qvariant
SOURCES
tst_bench_qvariant.cpp
- PUBLIC_LIBRARIES
- Qt::Gui
+ LIBRARIES
Qt::Test
)
## Scopes:
#####################################################################
-qt_internal_extend_target(tst_bench_qvariant CONDITION NOT TARGET Qt::Gui
- PUBLIC_LIBRARIES
- # Remove: gui
+qt_internal_extend_target(tst_bench_qvariant CONDITION TARGET Qt::Gui
+ LIBRARIES
+ Qt::Gui
)
diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp
index 157ec9b660..8b2e10c125 100644
--- a/tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp
+++ b/tests/benchmarks/corelib/kernel/qvariant/tst_bench_qvariant.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
#ifdef QT_GUI_LIB
diff --git a/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt b/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt
index 046564ba8e..e78d3250bc 100644
--- a/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt
+++ b/tests/benchmarks/corelib/kernel/qwineventnotifier/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qwineventnotifier Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qwineventnotifier
SOURCES
tst_bench_qwineventnotifier.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp b/tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp
index 4cfd1247b5..b1f87eabed 100644
--- a/tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp
+++ b/tests/benchmarks/corelib/kernel/qwineventnotifier/tst_bench_qwineventnotifier.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtCore/qglobal.h>
diff --git a/tests/benchmarks/corelib/mimetypes/CMakeLists.txt b/tests/benchmarks/corelib/mimetypes/CMakeLists.txt
index c825780e69..f66834de23 100644
--- a/tests/benchmarks/corelib/mimetypes/CMakeLists.txt
+++ b/tests/benchmarks/corelib/mimetypes/CMakeLists.txt
@@ -1,3 +1,4 @@
-# Generated from mimetypes.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qmimedatabase)
diff --git a/tests/benchmarks/corelib/mimetypes/qmimedatabase/CMakeLists.txt b/tests/benchmarks/corelib/mimetypes/qmimedatabase/CMakeLists.txt
index 9bddaf57bc..3d4eb7b46f 100644
--- a/tests/benchmarks/corelib/mimetypes/qmimedatabase/CMakeLists.txt
+++ b/tests/benchmarks/corelib/mimetypes/qmimedatabase/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qmimedatabase Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qmimedatabase
SOURCES
tst_bench_qmimedatabase.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp b/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp
index 3ecc700421..ffc65e7949 100644
--- a/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp
+++ b/tests/benchmarks/corelib/mimetypes/qmimedatabase/tst_bench_qmimedatabase.cpp
@@ -1,10 +1,12 @@
// Copyright (C) 2016 The Qt Company Ltd.
// Copyright (C) 2021 Igor Kushnir <igorkuo@gmail.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QMimeDatabase>
+using namespace Qt::StringLiterals;
+
namespace {
struct MatchModeInfo
{
@@ -51,26 +53,31 @@ void tst_QMimeDatabase::inheritsPerformance()
{
// Check performance of inherits().
// This benchmark (which started in 2009 in kmimetypetest.cpp) uses 40 mimetypes.
- QStringList mimeTypes;
- mimeTypes << QLatin1String("image/jpeg") << QLatin1String("image/png") << QLatin1String("image/tiff") << QLatin1String("text/plain") << QLatin1String("text/html");
- mimeTypes += mimeTypes;
- mimeTypes += mimeTypes;
- mimeTypes += mimeTypes;
- QCOMPARE(mimeTypes.count(), 40);
+ // (eight groups of five unique ones)
+ const QString uniqueMimeTypes[] = {
+ u"image/jpeg"_s,
+ u"image/png"_s,
+ u"image/tiff"_s,
+ u"text/plain"_s,
+ u"text/html"_s,
+ };
+ constexpr size_t NumOuterLoops = 40 / std::size(uniqueMimeTypes);
QMimeDatabase db;
- QMimeType mime = db.mimeTypeForName(QString::fromLatin1("text/x-chdr"));
+ const QMimeType mime = db.mimeTypeForName(u"text/x-chdr"_s);
QVERIFY(mime.isValid());
+ QString match;
QBENCHMARK {
- QString match;
- foreach (const QString &mt, mimeTypes) {
- if (mime.inherits(mt)) {
- match = mt;
- // of course there would normally be a "break" here, but we're testing worse-case
- // performance here
+ for (size_t i = 0; i < NumOuterLoops; ++i) {
+ for (const QString &mt : uniqueMimeTypes) {
+ if (mime.inherits(mt)) {
+ match = mt;
+ // of course there would normally be a "break" here, but
+ // we're testing worse-case performance here
+ }
}
}
- QCOMPARE(match, QString::fromLatin1("text/plain"));
}
+ QCOMPARE(match, u"text/plain"_s);
// Numbers from 2011, in release mode:
// KDE 4.7 numbers: 0.21 msec / 494,000 ticks / 568,345 instr. loads per iteration
// QMimeBinaryProvider (with Qt 5): 0.16 msec / NA / 416,049 instr. reads per iteration
diff --git a/tests/benchmarks/corelib/plugin/CMakeLists.txt b/tests/benchmarks/corelib/plugin/CMakeLists.txt
index 3ae12b23f5..fdfc6d8b8c 100644
--- a/tests/benchmarks/corelib/plugin/CMakeLists.txt
+++ b/tests/benchmarks/corelib/plugin/CMakeLists.txt
@@ -1,3 +1,4 @@
-# Generated from plugin.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(quuid)
diff --git a/tests/benchmarks/corelib/plugin/quuid/CMakeLists.txt b/tests/benchmarks/corelib/plugin/quuid/CMakeLists.txt
index 66ec60effc..2c394b2bb2 100644
--- a/tests/benchmarks/corelib/plugin/quuid/CMakeLists.txt
+++ b/tests/benchmarks/corelib/plugin/quuid/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_quuid Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_quuid
SOURCES
tst_bench_quuid.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_bench_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_bench_quuid.cpp
index b21f66d9e9..7a6da7f84c 100644
--- a/tests/benchmarks/corelib/plugin/quuid/tst_bench_quuid.cpp
+++ b/tests/benchmarks/corelib/plugin/quuid/tst_bench_quuid.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QCoreApplication>
#include <QtCore/QUuid>
diff --git a/tests/benchmarks/corelib/serialization/CMakeLists.txt b/tests/benchmarks/corelib/serialization/CMakeLists.txt
new file mode 100644
index 0000000000..98343d7688
--- /dev/null
+++ b/tests/benchmarks/corelib/serialization/CMakeLists.txt
@@ -0,0 +1,4 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+add_subdirectory(qcborvalue)
diff --git a/tests/benchmarks/corelib/serialization/qcborvalue/CMakeLists.txt b/tests/benchmarks/corelib/serialization/qcborvalue/CMakeLists.txt
new file mode 100644
index 0000000000..6ada5b983d
--- /dev/null
+++ b/tests/benchmarks/corelib/serialization/qcborvalue/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_benchmark(tst_bench_qcborvalue
+ SOURCES
+ tst_bench_qcborvalue.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::Test
+)
diff --git a/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp b/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp
new file mode 100644
index 0000000000..b9978fa25c
--- /dev/null
+++ b/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp
@@ -0,0 +1,95 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QCborMap>
+#include <QCborValue>
+
+#include <QTest>
+
+template <typename Char>
+struct SampleStrings
+{
+ static constexpr char key[] = "hello";
+};
+
+template <>
+struct SampleStrings<char16_t>
+{
+ static constexpr char16_t key[] = u"hello";
+};
+
+template <>
+struct SampleStrings<QChar>
+{
+ static const QChar *const key;
+};
+const QChar *const SampleStrings<QChar>::key =
+ reinterpret_cast<const QChar *>(SampleStrings<char16_t>::key);
+
+template <typename T, typename = void>
+constexpr bool hasValueType = false;
+
+template <typename T>
+constexpr bool hasValueType<T, std::void_t<typename T::value_type>> = true;
+
+class tst_QCborValue : public QObject
+{
+ Q_OBJECT
+private:
+ template <typename Type>
+ void doKeyLookup();
+
+ template <typename Type>
+ void doConstruct();
+
+private slots:
+ void keyLookupLatin1() { doKeyLookup<QLatin1StringView>(); }
+ void keyLookupString() { doKeyLookup<QString>(); }
+ void keyLookupConstCharPtr() { doKeyLookup<char>(); };
+
+ void constructLatin1() { doConstruct<QLatin1StringView>(); }
+ void constructString() { doConstruct<QString>(); }
+ void constructStringView() { doConstruct<QStringView>(); }
+ void constructConstCharPtr() { doConstruct<char>(); }
+};
+
+template <typename Type>
+void tst_QCborValue::doKeyLookup()
+{
+ const QCborMap m{{"hello", "world"}, {1, 2}};
+ const QCborValue v = m;
+
+ if constexpr (hasValueType<Type>) {
+ using Char = std::remove_cv_t<typename Type::value_type>;
+ using Strings = SampleStrings<Char>;
+ const Type s(Strings::key);
+ QBENCHMARK {
+ [[maybe_unused]] const QCborValue r = v[s];
+ }
+ } else {
+ QBENCHMARK {
+ [[maybe_unused]] const QCborValue r = v[SampleStrings<Type>::key];
+ }
+ }
+}
+
+template<typename Type>
+void tst_QCborValue::doConstruct()
+{
+ if constexpr (hasValueType<Type>) {
+ using Char = std::remove_cv_t<typename Type::value_type>;
+ using Strings = SampleStrings<Char>;
+ const Type s(Strings::key);
+ QBENCHMARK {
+ [[maybe_unused]] const auto v = QCborValue{s};
+ }
+ } else {
+ QBENCHMARK {
+ [[maybe_unused]] const auto v = QCborValue{SampleStrings<Type>::key};
+ }
+ }
+}
+
+QTEST_MAIN(tst_QCborValue)
+
+#include "tst_bench_qcborvalue.moc"
diff --git a/tests/benchmarks/corelib/text/CMakeLists.txt b/tests/benchmarks/corelib/text/CMakeLists.txt
index d0a2373822..303aa51def 100644
--- a/tests/benchmarks/corelib/text/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from text.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qbytearray)
add_subdirectory(qchar)
@@ -8,3 +9,4 @@ add_subdirectory(qstringlist)
add_subdirectory(qstringtokenizer)
add_subdirectory(qregularexpression)
add_subdirectory(qstring)
+add_subdirectory(qutf8stringview)
diff --git a/tests/benchmarks/corelib/text/qbytearray/CMakeLists.txt b/tests/benchmarks/corelib/text/qbytearray/CMakeLists.txt
index 18b811501b..1ea3660680 100644
--- a/tests/benchmarks/corelib/text/qbytearray/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qbytearray/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qbytearray Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qbytearray
SOURCES
tst_bench_qbytearray.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp b/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
index 05e20645d7..a97cba7c50 100644
--- a/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
+++ b/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2016 Intel Corporation.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
#include <QFile>
@@ -31,6 +31,9 @@ private slots:
void toPercentEncoding_data();
void toPercentEncoding();
+
+ void operator_assign_char();
+ void operator_assign_char_data();
};
void tst_QByteArray::initTestCase()
@@ -353,6 +356,38 @@ void tst_QByteArray::toPercentEncoding()
QTEST(encoded, "expected");
}
+void tst_QByteArray::operator_assign_char()
+{
+ QFETCH(QByteArray, data);
+ QString str(data.size(), Qt::Uninitialized);
+
+ const char *tdata = data.constData();
+ QBENCHMARK {
+ str.operator=(tdata);
+ }
+}
+
+void tst_QByteArray::operator_assign_char_data()
+{
+ QTest::addColumn<QByteArray>("data");
+
+ QByteArray data;
+ data.fill('a', 5);
+ QTest::newRow("length: 5") << data;
+ data.fill('b', 10);
+ QTest::newRow("length: 10") << data;
+ data.fill('c', 20);
+ QTest::newRow("length: 20") << data;
+ data.fill('d', 50);
+ QTest::newRow("length: 50") << data;
+ data.fill('e', 100);
+ QTest::newRow("length: 100") << data;
+ data.fill('f', 500);
+ QTest::newRow("length: 500") << data;
+ data.fill('g', 1'000);
+ QTest::newRow("length: 1'000") << data;
+}
+
QTEST_MAIN(tst_QByteArray)
#include "tst_bench_qbytearray.moc"
diff --git a/tests/benchmarks/corelib/text/qchar/CMakeLists.txt b/tests/benchmarks/corelib/text/qchar/CMakeLists.txt
index ef7f553f2e..136d3ef6fa 100644
--- a/tests/benchmarks/corelib/text/qchar/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qchar/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qchar Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qchar
SOURCES
tst_bench_qchar.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qchar/tst_bench_qchar.cpp b/tests/benchmarks/corelib/text/qchar/tst_bench_qchar.cpp
index b3ef96dfe1..194dd27d36 100644
--- a/tests/benchmarks/corelib/text/qchar/tst_bench_qchar.cpp
+++ b/tests/benchmarks/corelib/text/qchar/tst_bench_qchar.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QChar>
diff --git a/tests/benchmarks/corelib/text/qlocale/CMakeLists.txt b/tests/benchmarks/corelib/text/qlocale/CMakeLists.txt
index f319c0b5bd..04c2f69b9f 100644
--- a/tests/benchmarks/corelib/text/qlocale/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qlocale/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qlocale Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qlocale
SOURCES
tst_bench_qlocale.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qlocale/tst_bench_qlocale.cpp b/tests/benchmarks/corelib/text/qlocale/tst_bench_qlocale.cpp
index c32a78f5bd..3d13174c9c 100644
--- a/tests/benchmarks/corelib/text/qlocale/tst_bench_qlocale.cpp
+++ b/tests/benchmarks/corelib/text/qlocale/tst_bench_qlocale.cpp
@@ -1,9 +1,11 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QLocale>
#include <QTest>
+using namespace Qt::StringLiterals;
+
class tst_QLocale : public QObject
{
Q_OBJECT
@@ -29,6 +31,12 @@ private Q_SLOTS:
void toUpper_QLocale_2();
void toUpper_QString();
void number_QString();
+ void toLongLong_data();
+ void toLongLong();
+ void toULongLong_data();
+ void toULongLong();
+ void toDouble_data();
+ void toDouble();
};
static QString data()
@@ -367,6 +375,219 @@ void tst_QLocale::number_QString()
}
}
+template <typename Integer>
+void toWholeCommon_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<bool>("good");
+ QTest::addColumn<Integer>("expected");
+
+ QTest::newRow("C: empty") << u""_s << u"C"_s << false << Integer(0ull);
+ QTest::newRow("C: 0") << u"0"_s << u"C"_s << true << Integer(0ull);
+ QTest::newRow("C: 1234") << u"1234"_s << u"C"_s << true << Integer(1234ull);
+ // C locale omits grouping, but doesn't reject it.
+ QTest::newRow("C: 1,234") << u"1,234"_s << u"C"_s << true << Integer(1234ull);
+ QTest::newRow("C: 123456789")
+ << u"123456789"_s << u"C"_s << true << Integer(123456789ull);
+ QTest::newRow("C: 123,456,789")
+ << u"123,456,789"_s << u"C"_s << true << Integer(123456789ull);
+
+ QTest::newRow("en: empty") << u""_s << u"en"_s << false << Integer(0ull);
+ QTest::newRow("en: 0") << u"0"_s << u"en"_s << true << Integer(0ull);
+ QTest::newRow("en: 1234") << u"1234"_s << u"en"_s << true << Integer(1234ull);
+ QTest::newRow("en: 1,234") << u"1,234"_s << u"en"_s << true << Integer(1234ull);
+ QTest::newRow("en: 123,456,789")
+ << u"123,456,789"_s << u"en"_s << true << Integer(123456789ull);
+ QTest::newRow("en: 123456789")
+ << u"123456789"_s << u"en"_s << true << Integer(123456789ull);
+
+ QTest::newRow("de: empty") << u""_s << u"de"_s << false << Integer(0ull);
+ QTest::newRow("de: 0") << u"0"_s << u"de"_s << true << Integer(0ull);
+ QTest::newRow("de: 1234") << u"1234"_s << u"de"_s << true << Integer(1234ull);
+ QTest::newRow("de: 1.234") << u"1.234"_s << u"de"_s << true << Integer(1234ull);
+ QTest::newRow("de: 123.456.789")
+ << u"123.456.789"_s << u"de"_s << true << Integer(123456789ull);
+ QTest::newRow("de: 123456789")
+ << u"123456789"_s << u"de"_s << true << Integer(123456789ull);
+
+ // Locales with non-single-character signs:
+ QTest::newRow("ar_EG: +403") // Arabic, Egypt
+ << u"\u061c+\u0664\u0660\u0663"_s << u"ar_EG"_s << true << Integer(403ull);
+ QTest::newRow("ar_EG: !403") // Only first character of the sign
+ << u"\u061c\u0664\u0660\u0663"_s << u"ar_EG"_s << false << Integer(0ull);
+ QTest::newRow("fa_IR: +403") // Farsi, Iran
+ << u"\u200e+\u06f4\u06f0\u06f3"_s << u"fa_IR"_s << true << Integer(403ull);
+ QTest::newRow("fa_IR: !403") // Only first character of sign
+ << u"\u200e\u06f4\u06f0\u06f3"_s << u"fa_IR"_s << false << Integer(0ull);
+}
+
+void tst_QLocale::toLongLong_data()
+{
+ toWholeCommon_data<qlonglong>();
+
+ QTest::newRow("C: -1234") << u"-1234"_s << u"C"_s << true << -1234ll;
+ QTest::newRow("C: -123456789") << u"-123456789"_s << u"C"_s << true << -123456789ll;
+ QTest::newRow("C: qlonglong-max")
+ << u"9223372036854775807"_s << u"C"_s << true
+ << std::numeric_limits<qlonglong>::max();
+ QTest::newRow("C: qlonglong-min")
+ << u"-9223372036854775808"_s << u"C"_s << true
+ << std::numeric_limits<qlonglong>::min();
+
+ // Locales with multi-character signs:
+ QTest::newRow("ar_EG: -403") // Arabic, Egypt
+ << u"\u061c-\u0664\u0660\u0663"_s << u"ar_EG"_s << true << -403ll;
+ QTest::newRow("fa_IR: -403") // Farsi, Iran
+ << u"\u200e\u2212\u06f4\u06f0\u06f3"_s << u"fa_IR"_s << true << -403ll;
+}
+
+void tst_QLocale::toLongLong()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, locale);
+ QFETCH(bool, good);
+ QFETCH(qlonglong, expected);
+
+ const QLocale loc(locale);
+ qlonglong actual = expected;
+ bool ok = false;
+ QBENCHMARK {
+ actual = loc.toLongLong(text, &ok);
+ }
+ QCOMPARE(ok, good);
+ QCOMPARE(actual, expected);
+}
+
+void tst_QLocale::toULongLong_data()
+{
+ toWholeCommon_data<qulonglong>();
+
+ QTest::newRow("C: qlonglong-max + 1")
+ << u"9223372036854775808"_s << u"C"_s << true
+ << (qulonglong(std::numeric_limits<qlonglong>::max()) + 1);
+ QTest::newRow("C: qulonglong-max")
+ << u"18446744073709551615"_s << u"C"_s << true
+ << std::numeric_limits<qulonglong>::max();
+}
+
+void tst_QLocale::toULongLong()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, locale);
+ QFETCH(bool, good);
+ QFETCH(qulonglong, expected);
+
+ const QLocale loc(locale);
+ qulonglong actual = expected;
+ bool ok = false;
+ QBENCHMARK {
+ actual = loc.toULongLong(text, &ok);
+ }
+ QCOMPARE(ok, good);
+ QCOMPARE(actual, expected);
+}
+
+
+void tst_QLocale::toDouble_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<bool>("good");
+ QTest::addColumn<double>("expected");
+
+ QTest::newRow("C: empty") << u""_s << u"C"_s << false << 0.0;
+ QTest::newRow("C: 0") << u"0"_s << u"C"_s << true << 0.0;
+ QTest::newRow("C: 0.12340") << u"0.12340"_s << u"C"_s << true << 0.12340;
+ QTest::newRow("C: -0.12340") << u"-0.12340"_s << u"C"_s << true << -0.12340;
+ QTest::newRow("C: &minus;0.12340") << u"\u2212" "0.12340"_s << u"C"_s << true << -0.12340;
+ QTest::newRow("C: 1.0e-4") << u"1.0e-4"_s << u"C"_s << true << 1.0e-4;
+ QTest::newRow("C: 1.0e&minus;4") << u"1.0e\u2212" "4"_s << u"C"_s << true << 1.0e-4;
+ QTest::newRow("C: 1.0e+4") << u"1.0e+4"_s << u"C"_s << true << 1.0e+4;
+ QTest::newRow("C: 10.e+3") << u"10.e+3"_s << u"C"_s << true << 1.0e+4;
+ QTest::newRow("C: 10e+3.") << u"10e+3."_s << u"C"_s << false << 0.0; // exp...dot
+ QTest::newRow("C: 1e4") << u"1e4"_s << u"C"_s << true << 1.0e+4;
+
+ // NaN and infinity:
+ QTest::newRow("C: nan") << u"nan"_s << u"C"_s << true << qQNaN();
+ QTest::newRow("C: NaN") << u"NaN"_s << u"C"_s << true << qQNaN();
+ QTest::newRow("C: -nan") << u"-nan"_s << u"C"_s << false << 0.0;
+ QTest::newRow("C: +nan") << u"+nan"_s << u"C"_s << false << 0.0;
+ QTest::newRow("C: inf") << u"inf"_s << u"C"_s << true << qInf();
+ QTest::newRow("C: Inf") << u"Inf"_s << u"C"_s << true << qInf();
+ QTest::newRow("C: +inf") << u"+inf"_s << u"C"_s << true << qInf();
+ QTest::newRow("C: -inf") << u"-inf"_s << u"C"_s << true << -qInf();
+
+ // Wantonly long-form representations, with trailing and leading zeros:
+ QTest::newRow("C: 1e-64 long-form")
+ << (u"0."_s + QString(63, u'0') + u'1' + QString(962, u'0')) << u"C"_s << true << 1e-64;
+ QTest::newRow("C: 1e+64 long-form")
+ << (QString(961, u'0') + u'1' + QString(64, u'0') + u".0"_s) << u"C"_s << true << 1e+64;
+ QTest::newRow("C: long-form 1 via e+64")
+ << (u"0."_s + QString(63, u'0') + u'1' + QString(962, u'0') + u"e+64"_s)
+ << u"C"_s << true << 1.0;
+ QTest::newRow("C: long-form 1 via e-64")
+ << (QString(961, u'0') + u'1' + QString(64, u'0') + u".0e-64"_s)
+ << u"C"_s << true << 1.0;
+ QTest::newRow("C: 12345678.9") << u"12345678.9"_s << u"C"_s << true << 12345678.9;
+
+ // With and without grouping, en vs de for flipped separators:
+ QTest::newRow("en: 12345678.9") << u"12345678.9"_s << u"en"_s << true << 12345678.9;
+ QTest::newRow("en: 12,345,678.9") << u"12,345,678.9"_s << u"en"_s << true << 12'345'678.9;
+ QTest::newRow("de: 12345678,9") << u"12345678,9"_s << u"de"_s << true << 12345678.9;
+ QTest::newRow("de: 12.345.678,9") << u"12.345.678,9"_s << u"de"_s << true << 12'345'678.9;
+
+ // NaN and infinity are locale-independent (for now - QTBUG-95460)
+ QTest::newRow("cy: nan") << u"nan"_s << u"cy"_s << true << qQNaN();
+ QTest::newRow("cy: NaN") << u"NaN"_s << u"cy"_s << true << qQNaN();
+ QTest::newRow("cy: -nan") << u"-nan"_s << u"cy"_s << false << 0.0;
+ QTest::newRow("cy: +nan") << u"+nan"_s << u"cy"_s << false << 0.0;
+ QTest::newRow("cy: inf") << u"inf"_s << u"cy"_s << true << qInf();
+ QTest::newRow("cy: Inf") << u"Inf"_s << u"cy"_s << true << qInf();
+ QTest::newRow("cy: +inf") << u"+inf"_s << u"cy"_s << true << qInf();
+ QTest::newRow("cy: -inf") << u"-inf"_s << u"cy"_s << true << -qInf();
+ // Samples ready for QTBUG-95460:
+ QTest::newRow("en: &infin;") << u"\u221e"_s << u"en"_s << true << qInf();
+ QTest::newRow("ga: Nuimh") << u"Nuimh"_s << u"ga"_s << true << qQNaN();
+
+ // Locales with multi-character exponents:
+ QTest::newRow("sv_SE: 4e-3") // Swedish, Sweden
+ << u"4\u00d7" "10^\u2212" "03"_s << u"sv_SE"_s << true << 4e-3;
+ QTest::newRow("sv_SE: 4x-3") // Only first character of exponent
+ << u"4\u00d7\u2212" "03"_s << u"sv_SE"_s << false << 0.0;
+ QTest::newRow("se_NO: 4e-3") // Northern Sami, Norway
+ << u"4\u00b7" "10^\u2212" "03"_s << u"se_NO"_s << true << 4e-3;
+ QTest::newRow("se_NO: 4x-3") // Only first character of exponent
+ << u"4\u00b7\u2212" "03"_s << u"se_NO"_s << false << 0.0;
+ QTest::newRow("ar_EG: 4e-3") // Arabic, Egypt
+ << u"\u0664\u0627\u0633\u061c-\u0660\u0663"_s << u"ar_EG"_s << true << 4e-3;
+ QTest::newRow("ar_EG: 4x-3") // Only first character of exponent
+ << u"\u0664\u0627\u061c-\u0660\u0663"_s << u"ar_EG"_s << false << 0.0;
+ QTest::newRow("ar_EG: 4e!3") // Only first character of sign
+ << u"\u0664\u0627\u0633\u061c\u0660\u0663"_s << u"ar_EG"_s << false << 0.0;
+ QTest::newRow("ar_EG: 4x!3") // Only first character of sign and exponent
+ << u"\u0664\u0627\u061c\u0660\u0663"_s << u"ar_EG"_s << false << 0.0;
+}
+
+void tst_QLocale::toDouble()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, locale);
+ QFETCH(bool, good);
+ QFETCH(double, expected);
+
+ const QLocale loc(locale);
+ double actual = expected;
+ bool ok = false;
+ QBENCHMARK {
+ actual = loc.toDouble(text, &ok);
+ }
+ QEXPECT_FAIL("en: &infin;", "Localized infinity support missing: QTBUG-95460", Abort);
+ QEXPECT_FAIL("ga: Nuimh", "Localized NaN support missing: QTBUG-95460", Abort);
+ QCOMPARE(ok, good);
+ QCOMPARE(actual, expected);
+}
+
QTEST_MAIN(tst_QLocale)
#include "tst_bench_qlocale.moc"
diff --git a/tests/benchmarks/corelib/text/qregularexpression/CMakeLists.txt b/tests/benchmarks/corelib/text/qregularexpression/CMakeLists.txt
index 1e1f40a2e4..5d029439d0 100644
--- a/tests/benchmarks/corelib/text/qregularexpression/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qregularexpression/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qregularexpression.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qregularexpression Binary:
@@ -7,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qregularexpression
SOURCES
tst_bench_qregularexpression.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qregularexpression/tst_bench_qregularexpression.cpp b/tests/benchmarks/corelib/text/qregularexpression/tst_bench_qregularexpression.cpp
index 55eb4f2fed..83c87be0b1 100644
--- a/tests/benchmarks/corelib/text/qregularexpression/tst_bench_qregularexpression.cpp
+++ b/tests/benchmarks/corelib/text/qregularexpression/tst_bench_qregularexpression.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QRegularExpression>
#include <QTest>
diff --git a/tests/benchmarks/corelib/text/qstring/CMakeLists.txt b/tests/benchmarks/corelib/text/qstring/CMakeLists.txt
index c2ce102780..f17088d2be 100644
--- a/tests/benchmarks/corelib/text/qstring/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qstring/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qstring.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qstring Binary:
@@ -7,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qstring
SOURCES
tst_bench_qstring.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qstring/tst_bench_qstring.cpp b/tests/benchmarks/corelib/text/qstring/tst_bench_qstring.cpp
index f63f92463b..da5c0ff359 100644
--- a/tests/benchmarks/corelib/text/qstring/tst_bench_qstring.cpp
+++ b/tests/benchmarks/corelib/text/qstring/tst_bench_qstring.cpp
@@ -1,10 +1,14 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QStringList>
+#include <QByteArray>
+#include <QLatin1StringView>
#include <QFile>
#include <QTest>
#include <limits>
+using namespace Qt::StringLiterals;
+
class tst_QString: public QObject
{
Q_OBJECT
@@ -24,6 +28,7 @@ private slots:
void toCaseFolded_data();
void toCaseFolded();
+ // Serializing:
void number_qlonglong_data();
void number_qlonglong() { number_impl<qlonglong>(); }
void number_qulonglong_data();
@@ -32,10 +37,30 @@ private slots:
void number_double_data();
void number_double();
+ // Parsing:
+ void toLongLong_data();
+ void toLongLong();
+ void toULongLong_data();
+ void toULongLong();
+ void toDouble_data();
+ void toDouble();
+
+ // operator=(~)
+#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+ void operator_assign_BA() { operator_assign<QByteArray>(); }
+ void operator_assign_BA_data() { operator_assign_data(); }
+ void operator_assign_char() { operator_assign<const char*>(); };
+ void operator_assign_char_data() { operator_assign_data();}
+#endif
+ void operator_assign_L1SV() { operator_assign<QLatin1StringView>(); }
+ void operator_assign_L1SV_data() { operator_assign_data(); }
+
private:
void section_data_impl(bool includeRegExOnly = true);
template <typename RX> void section_impl();
template <typename Integer> void number_impl();
+ template <typename T> void operator_assign();
+ void operator_assign_data();
};
tst_QString::tst_QString()
@@ -189,6 +214,10 @@ void tst_QString::number_impl()
template <typename Integer>
void number_integer_common()
{
+ QTest::addColumn<Integer>("number");
+ QTest::addColumn<int>("base");
+ QTest::addColumn<QString>("expected");
+
QTest::newRow("0") << Integer(0ull) << 10 << QStringLiteral("0");
QTest::newRow("1234") << Integer(1234ull) << 10 << QStringLiteral("1234");
QTest::newRow("123456789") << Integer(123456789ull) << 10 << QStringLiteral("123456789");
@@ -200,10 +229,6 @@ void number_integer_common()
void tst_QString::number_qlonglong_data()
{
- QTest::addColumn<qlonglong>("number");
- QTest::addColumn<int>("base");
- QTest::addColumn<QString>("expected");
-
number_integer_common<qlonglong>();
QTest::newRow("-1234") << -1234ll << 10 << QStringLiteral("-1234");
@@ -230,10 +255,6 @@ void tst_QString::number_qlonglong_data()
void tst_QString::number_qulonglong_data()
{
- QTest::addColumn<qulonglong>("number");
- QTest::addColumn<int>("base");
- QTest::addColumn<QString>("expected");
-
number_integer_common<qulonglong>();
QTest::newRow("qlonglong-max + 1")
@@ -294,6 +315,196 @@ void tst_QString::number_double()
QCOMPARE(actual, expected);
}
+template <typename Integer>
+void toWholeCommon_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("base");
+ QTest::addColumn<bool>("good");
+ QTest::addColumn<Integer>("expected");
+
+ QTest::newRow("empty") << u""_s << 10 << false << Integer(0ull);
+ QTest::newRow("0") << u"0"_s << 10 << true << Integer(0ull);
+ QTest::newRow("1234") << u"1234"_s << 10 << true << Integer(1234ull);
+ QTest::newRow("1,234") << u"1,234"_s << 10 << false << Integer(0ull);
+ QTest::newRow("123456789")
+ << u"123456789"_s << 10 << true << Integer(123456789ull);
+ QTest::newRow("bad1dea, base 16")
+ << u"bad1dea"_s << 16 << true << Integer(0xBAD1DEAull);
+ QTest::newRow("bad1dea, base 10") << u"bad1dea"_s << 10 << false << Integer(0ull);
+ QTest::newRow("42, base 13") << u"42"_s << 13 << true << Integer(6ull * 9ull);
+ QTest::newRow("242, base 8") << u"242"_s << 8 << true << Integer(0242ull);
+ QTest::newRow("495, base 8") << u"495"_s << 8 << false << Integer(0ull);
+ QTest::newRow("101101, base 2")
+ << u"101101"_s << 2 << true << Integer(0b101101ull);
+ QTest::newRow("ad, base 30") << u"ad"_s << 30 << true << Integer(313ull);
+}
+
+void tst_QString::toLongLong_data()
+{
+ toWholeCommon_data<qlonglong>();
+
+ QTest::newRow("-1234") << u"-1234"_s << 10 << true << -1234ll;
+ QTest::newRow("-123456789") << u"-123456789"_s << 10 << true << -123456789ll;
+ QTest::newRow("-bad1dea, base 16") << u"-bad1dea"_s << 16 << true << -0xBAD1DEAll;
+ QTest::newRow("-242, base 8") << u"-242"_s << 8 << true << -0242ll;
+ QTest::newRow("-101101, base 2") << u"-101101"_s << 2 << true << -0b101101ll;
+ QTest::newRow("-ad, base 30") << u"-ad"_s << 30 << true << -313ll;
+
+ QTest::newRow("qlonglong-max")
+ << u"9223372036854775807"_s << 10 << true
+ << std::numeric_limits<qlonglong>::max();
+ QTest::newRow("qlonglong-min")
+ << u"-9223372036854775808"_s << 10 << true
+ << std::numeric_limits<qlonglong>::min();
+ QTest::newRow("qlonglong-max, base 2")
+ << QString(63, u'1') << 2 << true << std::numeric_limits<qlonglong>::max();
+ QTest::newRow("qlonglong-min, base 2")
+ << (u"-1"_s + QString(63, u'0')) << 2 << true
+ << std::numeric_limits<qlonglong>::min();
+ QTest::newRow("qlonglong-max, base 16")
+ << (QChar(u'7') + QString(15, u'f')) << 16 << true
+ << std::numeric_limits<qlonglong>::max();
+ QTest::newRow("qlonglong-min, base 16")
+ << (u"-8"_s + QString(15, u'0')) << 16 << true
+ << std::numeric_limits<qlonglong>::min();
+}
+
+void tst_QString::toLongLong()
+{
+ QFETCH(QString, text);
+ QFETCH(int, base);
+ QFETCH(bool, good);
+ QFETCH(qlonglong, expected);
+
+ qlonglong actual = expected;
+ bool ok = false;
+ QBENCHMARK {
+ actual = text.toLongLong(&ok, base);
+ }
+ QCOMPARE(ok, good);
+ QCOMPARE(actual, expected);
+}
+
+void tst_QString::toULongLong_data()
+{
+ toWholeCommon_data<qulonglong>();
+
+ QTest::newRow("qlonglong-max + 1")
+ << u"9223372036854775808"_s << 10 << true
+ << (qulonglong(std::numeric_limits<qlonglong>::max()) + 1);
+ QTest::newRow("qulonglong-max")
+ << u"18446744073709551615"_s << 10 << true
+ << std::numeric_limits<qulonglong>::max();
+ QTest::newRow("qulonglong-max, base 2")
+ << QString(64, u'1') << 2 << true << std::numeric_limits<qulonglong>::max();
+ QTest::newRow("qulonglong-max, base 16")
+ << QString(16, u'f') << 16 << true << std::numeric_limits<qulonglong>::max();
+}
+
+void tst_QString::toULongLong()
+{
+ QFETCH(QString, text);
+ QFETCH(int, base);
+ QFETCH(bool, good);
+ QFETCH(qulonglong, expected);
+
+ qulonglong actual = expected;
+ bool ok = false;
+ QBENCHMARK {
+ actual = text.toULongLong(&ok, base);
+ }
+ QCOMPARE(ok, good);
+ QCOMPARE(actual, expected);
+}
+
+void tst_QString::toDouble_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("good");
+ QTest::addColumn<double>("expected");
+
+ QTest::newRow("empty") << u""_s << false << 0.0;
+ QTest::newRow("0") << u"0"_s << true << 0.0;
+ QTest::newRow("0.12340") << u"0.12340"_s << true << 0.12340;
+ QTest::newRow("-0.12340") << u"-0.12340"_s << true << -0.12340;
+ QTest::newRow("epsilon")
+ << u"2.220446049e-16"_s << true << std::numeric_limits<double>::epsilon();
+ QTest::newRow("1.0e-4") << u"1.0e-4"_s << true << 1.0e-4;
+ QTest::newRow("1.0e+4") << u"1.0e+4"_s << true << 1.0e+4;
+ QTest::newRow("10.e+3") << u"10.e+3"_s << true << 1.0e+4;
+ QTest::newRow("10e+3.") << u"10e+3."_s << false << 0.0;
+ QTest::newRow("1e4") << u"1e4"_s << true << 1.0e+4;
+ QTest::newRow("1.0e-8") << u"1.0e-8"_s << true << 1.0e-8;
+ QTest::newRow("1.0e+8") << u"1.0e+8"_s << true << 1.0e+8;
+
+ // NaN and infinity:
+ QTest::newRow("nan") << u"nan"_s << true << qQNaN();
+ QTest::newRow("NaN") << u"NaN"_s << true << qQNaN();
+ QTest::newRow("-nan") << u"-nan"_s << false << 0.0;
+ QTest::newRow("+nan") << u"+nan"_s << false << 0.0;
+ QTest::newRow("inf") << u"inf"_s << true << qInf();
+ QTest::newRow("Inf") << u"Inf"_s << true << qInf();
+ QTest::newRow("+inf") << u"+inf"_s << true << qInf();
+ QTest::newRow("-inf") << u"-inf"_s << true << -qInf();
+}
+
+void tst_QString::toDouble()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, good);
+ QFETCH(double, expected);
+
+ double actual = expected;
+ bool ok = false;
+ QBENCHMARK {
+ actual = text.toDouble(&ok);
+ }
+ QCOMPARE(ok, good);
+ QCOMPARE(actual, expected);
+}
+
+template <typename T> void tst_QString::operator_assign()
+{
+ QFETCH(QByteArray, data);
+ QString str(data.size(), Qt::Uninitialized);
+
+ T tdata;
+ if constexpr (std::is_same_v<T, const char*>) {
+ tdata = data.constData();
+ } else if constexpr (std::is_same_v<T, QLatin1String>) {
+ tdata = T(data.constData(), data.size());
+ } else {
+ tdata = T(data.constData(), data.size());
+ tdata.detach();
+ }
+
+ QBENCHMARK {
+ str.operator=(tdata);
+ }
+}
+
+void tst_QString::operator_assign_data()
+{
+ QTest::addColumn<QByteArray>("data");
+
+ QByteArray data;
+ data.fill('a', 5);
+ QTest::newRow("length: 5") << data;
+ data.fill('b', 10);
+ QTest::newRow("length: 10") << data;
+ data.fill('c', 20);
+ QTest::newRow("length: 20") << data;
+ data.fill('d', 50);
+ QTest::newRow("length: 50") << data;
+ data.fill('e', 100);
+ QTest::newRow("length: 100") << data;
+ data.fill('f', 500);
+ QTest::newRow("length: 500") << data;
+ data.fill('g', 1'000);
+ QTest::newRow("length: 1'000") << data;
+}
+
QTEST_APPLESS_MAIN(tst_QString)
#include "tst_bench_qstring.moc"
diff --git a/tests/benchmarks/corelib/text/qstringbuilder/CMakeLists.txt b/tests/benchmarks/corelib/text/qstringbuilder/CMakeLists.txt
index b450aa50a0..c3c95e233c 100644
--- a/tests/benchmarks/corelib/text/qstringbuilder/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qstringbuilder/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qstringbuilder Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qstringbuilder
SOURCES
tst_bench_qstringbuilder.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
COMPILE_OPTIONS
-g
diff --git a/tests/benchmarks/corelib/text/qstringbuilder/tst_bench_qstringbuilder.cpp b/tests/benchmarks/corelib/text/qstringbuilder/tst_bench_qstringbuilder.cpp
index 8946897160..496abdaf3b 100644
--- a/tests/benchmarks/corelib/text/qstringbuilder/tst_bench_qstringbuilder.cpp
+++ b/tests/benchmarks/corelib/text/qstringbuilder/tst_bench_qstringbuilder.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Select one of the scenarios below
#define SCENARIO 1
diff --git a/tests/benchmarks/corelib/text/qstringlist/CMakeLists.txt b/tests/benchmarks/corelib/text/qstringlist/CMakeLists.txt
index 58af3c9dd3..da2f84d6e9 100644
--- a/tests/benchmarks/corelib/text/qstringlist/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qstringlist/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qstringlist Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qstringlist
SOURCES
tst_bench_qstringlist.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qstringlist/tst_bench_qstringlist.cpp b/tests/benchmarks/corelib/text/qstringlist/tst_bench_qstringlist.cpp
index ee0789261c..2431446bf6 100644
--- a/tests/benchmarks/corelib/text/qstringlist/tst_bench_qstringlist.cpp
+++ b/tests/benchmarks/corelib/text/qstringlist/tst_bench_qstringlist.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QStringList>
#include <QTest>
@@ -8,6 +8,8 @@
#include <string>
#include <vector>
+using namespace Qt::StringLiterals;
+
class tst_QStringList: public QObject
{
Q_OBJECT
@@ -19,6 +21,11 @@ private slots:
void removeDuplicates() const;
void removeDuplicates_data() const;
+ void filter_data() const;
+ void filter() const;
+ void filter_stringMatcher_data() const { filter_data(); }
+ void filter_stringMatcher() const;
+
void split_qlist_qbytearray() const;
void split_qlist_qbytearray_data() const { return split_data(); }
@@ -43,9 +50,9 @@ private:
QStringList tst_QStringList::populateList(const int count, const QString &unit)
{
QStringList retval;
-
+ retval.reserve(count);
for (int i = 0; i < count; ++i)
- retval.append(unit);
+ retval.append(unit + QString::number(i));
return retval;
}
@@ -77,20 +84,20 @@ void tst_QStringList::join_data() const
QTest::addColumn<QStringList>("input");
QTest::addColumn<QString>("separator");
- QTest::newRow("")
+ QTest::newRow("100")
<< populateList(100, QLatin1String("unit"))
<< QString();
- QTest::newRow("")
+ QTest::newRow("1000")
<< populateList(1000, QLatin1String("unit"))
<< QString();
- QTest::newRow("")
- << populateList(10000, QLatin1String("unit"))
+ QTest::newRow("10000")
+ << populateList(10'000, QLatin1String("unit"))
<< QString();
- QTest::newRow("")
- << populateList(100000, QLatin1String("unit"))
+ QTest::newRow("100000")
+ << populateList(100'000, QLatin1String("unit"))
<< QString();
}
@@ -130,6 +137,39 @@ void tst_QStringList::removeDuplicates_data() const
QTest::addRow("long-dup-0.75") << (l + l + l + l);
}
+void tst_QStringList::filter_data() const
+{
+ QTest::addColumn<QStringList>("list");
+ QTest::addColumn<QStringList>("expected");
+
+ for (int i : {10, 20, 30, 40, 50, 70, 80, 100, 300, 500, 700, 900, 10'000}) {
+ QStringList list = populateList(i, u"A rather long string to test QStringMatcher"_s);
+ list.append(u"Horse and cart from old"_s);
+ QTest::addRow("list%d", i) << list << QStringList(u"Horse and cart from old"_s);
+ }
+}
+
+void tst_QStringList::filter() const
+{
+ QFETCH(QStringList, list);
+ QFETCH(QStringList, expected);
+
+ QBENCHMARK {
+ QCOMPARE(list.filter(u"Horse and cart from old", Qt::CaseSensitive), expected);
+ }
+}
+
+void tst_QStringList::filter_stringMatcher() const
+{
+ QFETCH(QStringList, list);
+ QFETCH(QStringList, expected);
+
+ const QStringMatcher matcher(u"Horse and cart from old", Qt::CaseSensitive);
+ QBENCHMARK {
+ QCOMPARE(list.filter(matcher), expected);
+ }
+}
+
void tst_QStringList::split_data() const
{
QTest::addColumn<QString>("input");
diff --git a/tests/benchmarks/corelib/text/qstringtokenizer/CMakeLists.txt b/tests/benchmarks/corelib/text/qstringtokenizer/CMakeLists.txt
index 92dd6cec98..11720e5204 100644
--- a/tests/benchmarks/corelib/text/qstringtokenizer/CMakeLists.txt
+++ b/tests/benchmarks/corelib/text/qstringtokenizer/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qstringtokenizer Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qstringtokenizer
SOURCES
tst_bench_qstringtokenizer.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/text/qstringtokenizer/tst_bench_qstringtokenizer.cpp b/tests/benchmarks/corelib/text/qstringtokenizer/tst_bench_qstringtokenizer.cpp
index 38f55069b7..eccfad91da 100644
--- a/tests/benchmarks/corelib/text/qstringtokenizer/tst_bench_qstringtokenizer.cpp
+++ b/tests/benchmarks/corelib/text/qstringtokenizer/tst_bench_qstringtokenizer.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QTest>
diff --git a/tests/benchmarks/corelib/text/qutf8stringview/CMakeLists.txt b/tests/benchmarks/corelib/text/qutf8stringview/CMakeLists.txt
new file mode 100644
index 0000000000..14613afe56
--- /dev/null
+++ b/tests/benchmarks/corelib/text/qutf8stringview/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_bench_qutf8stringview Binary:
+#####################################################################
+
+qt_internal_add_benchmark(tst_bench_qutf8stringview
+ SOURCES
+ tst_bench_qutf8stringview.cpp
+ LIBRARIES
+ Qt::Test
+ Qt::CorePrivate
+)
diff --git a/tests/benchmarks/corelib/text/qutf8stringview/tst_bench_qutf8stringview.cpp b/tests/benchmarks/corelib/text/qutf8stringview/tst_bench_qutf8stringview.cpp
new file mode 100644
index 0000000000..ec633ff67d
--- /dev/null
+++ b/tests/benchmarks/corelib/text/qutf8stringview/tst_bench_qutf8stringview.cpp
@@ -0,0 +1,263 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qbytearray.h>
+#include <qdebug.h>
+#include <qstring.h>
+#include <qtest.h>
+#include <qutf8stringview.h>
+
+class tst_QUtf8StringView : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void equalStringsLatin1_data() { equalStrings_data(); }
+ void equalStringsLatin1();
+ void equalStringsUtf16_data() { equalStrings_data(); }
+ void equalStringsUtf16();
+ void equalStringsUtf8_data() { equalStrings_data(); }
+ void equalStringsUtf8();
+
+ void compareStringsCaseSensitiveLatin1_data() { compareStringsCaseSensitive_data(); }
+ void compareStringsCaseSensitiveLatin1() { compareStringsLatin1(true); }
+ void compareStringsCaseSensitiveUtf16_data() { compareStringsCaseSensitive_data(); }
+ void compareStringsCaseSensitiveUtf16() { compareStringsUtf16(true); }
+ void compareStringsCaseSensitiveUtf8_data() { compareStringsCaseSensitive_data(); }
+ void compareStringsCaseSensitiveUtf8() { compareStringsUtf8(true); }
+
+ void compareStringsCaseInsensitiveLatin1_data() { compareStringsCaseInsensitive_data(); }
+ void compareStringsCaseInsensitiveLatin1() { compareStringsLatin1(false); }
+ void compareStringsCaseInsensitiveUtf16_data() { compareStringsCaseInsensitive_data(); }
+ void compareStringsCaseInsensitiveUtf16() { compareStringsUtf16(false); }
+ void compareStringsCaseInsensitiveUtf8_data() { compareStringsCaseInsensitive_data(); }
+ void compareStringsCaseInsensitiveUtf8() { compareStringsUtf8(false); }
+
+ void compareStringsWithErrors_data();
+ void compareStringsWithErrors();
+
+private:
+ void equalStrings_data();
+ void compareStringsCaseSensitive_data();
+ void compareStringsCaseInsensitive_data();
+ void compareStringsLatin1(bool caseSensitive);
+ void compareStringsUtf16(bool caseSensitive);
+ void compareStringsUtf8(bool caseSensitive);
+};
+
+void tst_QUtf8StringView::equalStrings_data()
+{
+ QTest::addColumn<QString>("lhs");
+ QTest::addColumn<QString>("rhs");
+ QTest::addColumn<bool>("isEqual");
+
+ QTest::newRow("EqualStrings") << "Test"
+ << "Test" << true;
+ QTest::newRow("EqualStringsLong")
+ << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" << true;
+ QTest::newRow("DifferentCase") << "test"
+ << "Test" << false;
+ QTest::newRow("DifferentCaseLong")
+ << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ << "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" << false;
+ QTest::newRow("ReverseStrings") << "Test"
+ << "tseT" << false;
+ QTest::newRow("Latin1RangeCharacter") << u8"B\u00d8" << u8"B\u00d8" << true;
+ QTest::newRow("Latin1RangeCharacterDifferentCase") << u8"B\u00d8" << u8"B\u00f8" << false;
+}
+
+void tst_QUtf8StringView::equalStringsLatin1()
+{
+ QFETCH(QString, lhs);
+ QFETCH(QString, rhs);
+ QFETCH(bool, isEqual);
+ QByteArray left = lhs.toUtf8();
+ QByteArray right = rhs.toLatin1();
+ QBasicUtf8StringView<false> lhv(left);
+ QLatin1StringView rhv(right);
+ bool result;
+
+ QBENCHMARK {
+ result = QtPrivate::equalStrings(lhv, rhv);
+ };
+ QCOMPARE(result, isEqual);
+}
+
+void tst_QUtf8StringView::equalStringsUtf16()
+{
+ QFETCH(QString, lhs);
+ QFETCH(QString, rhs);
+ QFETCH(bool, isEqual);
+
+ QByteArray left = lhs.toUtf8();
+ QBasicUtf8StringView<false> lhv(left);
+ QStringView rhv(rhs);
+ bool result;
+
+ QBENCHMARK {
+ result = QtPrivate::equalStrings(lhv, rhv);
+ };
+ QCOMPARE(result, isEqual);
+}
+
+void tst_QUtf8StringView::equalStringsUtf8()
+{
+ QFETCH(QString, lhs);
+ QFETCH(QString, rhs);
+ QFETCH(bool, isEqual);
+
+ QByteArray left = lhs.toUtf8();
+ QByteArray right = rhs.toUtf8();
+ QBasicUtf8StringView<false> lhv(left);
+ QBasicUtf8StringView<false> rhv(right);
+ bool result;
+
+ QBENCHMARK {
+ result = QtPrivate::equalStrings(lhv, rhv);
+ };
+ QCOMPARE(result, isEqual);
+}
+
+void tst_QUtf8StringView::compareStringsCaseSensitive_data()
+{
+ QTest::addColumn<QString>("lhs");
+ QTest::addColumn<QString>("rhs");
+ QTest::addColumn<int>("compareValue");
+
+ QTest::newRow("EqualStrings") << "Test"
+ << "Test" << 0;
+ QTest::newRow("EqualStringsLong") << "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"
+ << "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ" << 0;
+ QTest::newRow("DifferentCase") << "test"
+ << "Test" << 32;
+ QTest::newRow("DifferentCaseLong")
+ << "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"
+ << "abcdefghijklmnopqrstuvxyzabcdefghijklmnopqrstuvxyz" << -32;
+ QTest::newRow("ReverseStrings") << "Test"
+ << "tseT" << -32;
+ QTest::newRow("Different Strings") << "Testing and testing"
+ << "Testing and resting" << 2;
+ QTest::newRow("Latin1RangeCharacter") << u8"B\u00d8" << u8"B\u00d8" << 0;
+ QTest::newRow("Latin1RangeCharacterDifferentCase") << u8"B\u00d8" << u8"B\u00f8" << -32;
+}
+
+void tst_QUtf8StringView::compareStringsCaseInsensitive_data()
+{
+ QTest::addColumn<QString>("lhs");
+ QTest::addColumn<QString>("rhs");
+ QTest::addColumn<int>("compareValue");
+
+ QTest::newRow("EqualStrings") << "Test"
+ << "Test" << 0;
+ QTest::newRow("EqualStringsLong") << "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"
+ << "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ" << 0;
+ QTest::newRow("DifferentCase") << "test"
+ << "Test" << 0;
+ QTest::newRow("DifferentCaseLong") << "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"
+ << "abcdefghijklmnopqrstuvxyzabcdefghijklmnopqrstuvxyz" << 0;
+ QTest::newRow("ReverseStrings") << "Test"
+ << "tseT" << -14;
+ QTest::newRow("Different Strings") << "Testing and testing"
+ << "Testing and resting" << 2;
+ QTest::newRow("Latin1RangeCharacter") << u8"B\u00d8" << u8"B\u00d8" << 0;
+ QTest::newRow("Latin1RangeCharacterDifferentCase") << u8"B\u00d8" << u8"B\u00f8" << 0;
+}
+
+void tst_QUtf8StringView::compareStringsLatin1(bool caseSensitive)
+{
+ QFETCH(QString, lhs);
+ QFETCH(QString, rhs);
+ QFETCH(int, compareValue);
+ QByteArray left = lhs.toUtf8();
+ QByteArray right = rhs.toLatin1();
+ QBasicUtf8StringView<false> lhv(left);
+ QLatin1StringView rhv(right);
+ Qt::CaseSensitivity cs = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ int result;
+
+ QBENCHMARK {
+ result = lhv.compare(rhv, cs);
+ };
+ QCOMPARE(result, compareValue);
+}
+
+void tst_QUtf8StringView::compareStringsUtf16(bool caseSensitive)
+{
+ QFETCH(QString, lhs);
+ QFETCH(QString, rhs);
+ QFETCH(int, compareValue);
+
+ QByteArray left = lhs.toUtf8();
+ QBasicUtf8StringView<false> lhv(left);
+ QStringView rhv(rhs);
+ Qt::CaseSensitivity cs = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ int result;
+
+ QBENCHMARK {
+ result = lhv.compare(rhv, cs);
+ };
+ QCOMPARE(result, compareValue);
+}
+
+void tst_QUtf8StringView::compareStringsUtf8(bool caseSensitive)
+{
+ QFETCH(QString, lhs);
+ QFETCH(QString, rhs);
+ QFETCH(int, compareValue);
+
+ QByteArray left = lhs.toUtf8();
+ QByteArray right = rhs.toUtf8();
+ QBasicUtf8StringView<false> lhv(left);
+ QBasicUtf8StringView<false> rhv(right);
+ Qt::CaseSensitivity cs = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ int result;
+
+ QBENCHMARK {
+ result = lhv.compare(rhv, cs);
+ };
+ QCOMPARE(result, compareValue);
+}
+
+void tst_QUtf8StringView::compareStringsWithErrors_data()
+{
+ QTest::addColumn<QByteArray>("lhs");
+ QTest::addColumn<QByteArray>("rhs");
+ QTest::addColumn<int>("compare");
+ QTest::addColumn<bool>("caseSensitive");
+
+ QTest::newRow("Compare errors 0xfe vs 0xff case-insensitive")
+ << QByteArray("\xfe") << QByteArray("\xff") << 0 << false;
+ QTest::newRow("Compare errors 0xff vs 0xff case-insensitive")
+ << QByteArray("\xff") << QByteArray("\xff") << 0 << false;
+ QTest::newRow("Compare 'a' with error 0xff case-insensitive")
+ << QByteArray("a") << QByteArray("\xff") << -65436 << false;
+ QTest::newRow("Compare errors 0xfe vs 0xff case-sensitive")
+ << QByteArray("\xfe") << QByteArray("\xff") << -1 << true;
+ QTest::newRow("Compare errors 0xff vs 0xff case-sensitive")
+ << QByteArray("\xff") << QByteArray("\xff") << 0 << true;
+ QTest::newRow("Compare 'a' with error 0xff case-sensitive")
+ << QByteArray("a") << QByteArray("\xff") << -158 << true;
+}
+
+void tst_QUtf8StringView::compareStringsWithErrors()
+{
+ QFETCH(QByteArray, lhs);
+ QFETCH(QByteArray, rhs);
+ QFETCH(int, compare);
+ QFETCH(bool, caseSensitive);
+ QBasicUtf8StringView<false> lhv(lhs);
+ QBasicUtf8StringView<false> rhv(rhs);
+ Qt::CaseSensitivity cs = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ int result;
+
+ QBENCHMARK {
+ result = lhv.compare(rhv, cs);
+ };
+ QCOMPARE(result, compare);
+ QCOMPARE(-result, rhv.compare(lhv, cs));
+}
+
+QTEST_MAIN(tst_QUtf8StringView)
+
+#include "tst_bench_qutf8stringview.moc"
diff --git a/tests/benchmarks/corelib/thread/CMakeLists.txt b/tests/benchmarks/corelib/thread/CMakeLists.txt
index 8f7b829a40..48bf0572a6 100644
--- a/tests/benchmarks/corelib/thread/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from thread.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qfuture)
add_subdirectory(qmutex)
diff --git a/tests/benchmarks/corelib/thread/qfuture/CMakeLists.txt b/tests/benchmarks/corelib/thread/qfuture/CMakeLists.txt
index d53e3f6728..5988b1c0b0 100644
--- a/tests/benchmarks/corelib/thread/qfuture/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/qfuture/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qfuture Binary:
#####################################################################
@@ -6,6 +9,6 @@ qt_internal_add_benchmark(tst_bench_qfuture
EXCEPTIONS
SOURCES
tst_bench_qfuture.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp b/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp
index 7c0e3b2fcf..38b3f636c9 100644
--- a/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp
+++ b/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -13,7 +13,7 @@ class tst_QFuture : public QObject
Q_OBJECT
private slots:
- void makeReadyfuture();
+ void makeReadyValueFuture();
#ifndef QT_NO_EXCEPTIONS
void makeExceptionalFuture();
#endif
@@ -43,10 +43,10 @@ private slots:
void progressText();
};
-void tst_QFuture::makeReadyfuture()
+void tst_QFuture::makeReadyValueFuture()
{
QBENCHMARK {
- auto future = QtFuture::makeReadyFuture(42);
+ auto future = QtFuture::makeReadyValueFuture(42);
Q_UNUSED(future);
}
}
@@ -64,7 +64,7 @@ void tst_QFuture::makeExceptionalFuture()
void tst_QFuture::result()
{
- auto future = QtFuture::makeReadyFuture(42);
+ auto future = QtFuture::makeReadyValueFuture(42);
QBENCHMARK {
auto value = future.result();
@@ -92,7 +92,7 @@ void tst_QFuture::results()
void tst_QFuture::takeResult()
{
QBENCHMARK {
- auto future = QtFuture::makeReadyFuture(42);
+ auto future = QtFuture::makeReadyValueFuture(42);
auto value = future.takeResult();
Q_UNUSED(value);
}
@@ -140,7 +140,7 @@ void tst_QFuture::reportException()
void tst_QFuture::then()
{
- auto f = QtFuture::makeReadyFuture(42);
+ auto f = QtFuture::makeReadyValueFuture(42);
QBENCHMARK {
auto future = f.then([](int value) { return value; });
Q_UNUSED(future);
@@ -149,7 +149,7 @@ void tst_QFuture::then()
void tst_QFuture::thenVoid()
{
- auto f = QtFuture::makeReadyFuture();
+ auto f = QtFuture::makeReadyVoidFuture();
QBENCHMARK {
auto future = f.then([] {});
Q_UNUSED(future);
@@ -205,7 +205,7 @@ void tst_QFuture::onFailedVoid()
void tst_QFuture::thenOnFailed()
{
- auto f = QtFuture::makeReadyFuture(42);
+ auto f = QtFuture::makeReadyValueFuture(42);
QBENCHMARK {
auto future =
f.then([](int) { throw std::runtime_error("error"); }).onFailed([] { return 0; });
@@ -215,7 +215,7 @@ void tst_QFuture::thenOnFailed()
void tst_QFuture::thenOnFailedVoid()
{
- auto f = QtFuture::makeReadyFuture();
+ auto f = QtFuture::makeReadyVoidFuture();
QBENCHMARK {
auto future = f.then([] { throw std::runtime_error("error"); }).onFailed([] {});
Q_UNUSED(future);
diff --git a/tests/benchmarks/corelib/thread/qmutex/CMakeLists.txt b/tests/benchmarks/corelib/thread/qmutex/CMakeLists.txt
index d056a10568..2d01f9ff1f 100644
--- a/tests/benchmarks/corelib/thread/qmutex/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/qmutex/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qmutex Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qmutex
SOURCES
tst_bench_qmutex.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp
index ff651eebae..6ea0c25c0b 100644
--- a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp
+++ b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtCore>
#include <QTest>
@@ -9,6 +9,8 @@
//#define USE_SEM_T
+using namespace std::chrono_literals;
+
#if defined(Q_OS_UNIX)
#if !defined(USE_SEM_T)
# include <pthread.h>
@@ -51,9 +53,6 @@ void NativeMutexUnlock(NativeMutexType *mutex)
}
#endif
#elif defined(Q_OS_WIN)
-# if !defined(_WIN32_WINNT)
-# define _WIN32_WINNT 0x0A00
-# endif
# include <qt_windows.h>
typedef CRITICAL_SECTION NativeMutexType;
void NativeMutexInitialize(NativeMutexType *mutex)
@@ -231,7 +230,8 @@ void tst_QMutex::contendedNative_data()
class NativeMutexThread : public QThread
{
NativeMutexType *mutex1, *mutex2;
- int iterations, msleepDuration;
+ int iterations;
+ std::chrono::milliseconds msleepDuration;
bool use2mutexes;
public:
bool done;
@@ -249,8 +249,8 @@ public:
NativeMutexLock(mutex1);
if (use2mutexes)
NativeMutexLock(mutex2);
- if (msleepDuration >= 0)
- msleep(msleepDuration);
+ if (msleepDuration >= 0ms)
+ sleep(msleepDuration);
if (use2mutexes)
NativeMutexUnlock(mutex2);
NativeMutexUnlock(mutex1);
@@ -274,7 +274,7 @@ void tst_QMutex::contendedNative()
NativeMutexInitialize(&mutex2);
QList<NativeMutexThread *> threads(threadCount);
- for (int i = 0; i < threads.count(); ++i) {
+ for (int i = 0; i < threads.size(); ++i) {
threads[i] = new NativeMutexThread(&mutex1, &mutex2, iterations, msleepDuration, use2mutexes);
threads[i]->start();
}
@@ -286,11 +286,11 @@ void tst_QMutex::contendedNative()
semaphore4.release(threadCount);
}
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->done = true;
semaphore1.acquire(threadCount);
semaphore2.release(threadCount);
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->wait();
qDeleteAll(threads);
@@ -301,7 +301,8 @@ void tst_QMutex::contendedNative()
class QMutexThread : public QThread
{
QMutex *mutex1, *mutex2;
- int iterations, msleepDuration;
+ int iterations;
+ std::chrono::milliseconds msleepDuration;
bool use2mutexes;
public:
bool done;
@@ -319,8 +320,8 @@ public:
mutex1->lock();
if (use2mutexes)
mutex2->lock();
- if (msleepDuration >= 0)
- msleep(msleepDuration);
+ if (msleepDuration >= 0ms)
+ sleep(msleepDuration);
if (use2mutexes)
mutex2->unlock();
mutex1->unlock();
@@ -342,7 +343,7 @@ void tst_QMutex::contendedQMutex()
QMutex mutex1, mutex2;
QList<QMutexThread *> threads(threadCount);
- for (int i = 0; i < threads.count(); ++i) {
+ for (int i = 0; i < threads.size(); ++i) {
threads[i] = new QMutexThread(&mutex1, &mutex2, iterations, msleepDuration, use2mutexes);
threads[i]->start();
}
@@ -354,11 +355,11 @@ void tst_QMutex::contendedQMutex()
semaphore4.release(threadCount);
}
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->done = true;
semaphore1.acquire(threadCount);
semaphore2.release(threadCount);
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->wait();
qDeleteAll(threads);
}
@@ -366,7 +367,8 @@ void tst_QMutex::contendedQMutex()
class QMutexLockerThread : public QThread
{
QMutex *mutex1, *mutex2;
- int iterations, msleepDuration;
+ int iterations;
+ std::chrono::milliseconds msleepDuration;
bool use2mutexes;
public:
bool done;
@@ -384,8 +386,8 @@ public:
{
QMutexLocker locker1(mutex1);
QMutexLocker locker2(use2mutexes ? mutex2 : 0);
- if (msleepDuration >= 0)
- msleep(msleepDuration);
+ if (msleepDuration >= 0ms)
+ sleep(msleepDuration);
}
QThread::yieldCurrentThread();
@@ -405,7 +407,7 @@ void tst_QMutex::contendedQMutexLocker()
QMutex mutex1, mutex2;
QList<QMutexLockerThread *> threads(threadCount);
- for (int i = 0; i < threads.count(); ++i) {
+ for (int i = 0; i < threads.size(); ++i) {
threads[i] = new QMutexLockerThread(&mutex1, &mutex2, iterations, msleepDuration, use2mutexes);
threads[i]->start();
}
@@ -417,11 +419,11 @@ void tst_QMutex::contendedQMutexLocker()
semaphore4.release(threadCount);
}
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->done = true;
semaphore1.acquire(threadCount);
semaphore2.release(threadCount);
- for (int i = 0; i < threads.count(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->wait();
qDeleteAll(threads);
}
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/CMakeLists.txt b/tests/benchmarks/corelib/thread/qreadwritelock/CMakeLists.txt
index 901f9609bc..b56f484b48 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qreadwritelock Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qreadwritelock
SOURCES
tst_bench_qreadwritelock.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp
index a41002e5fe..e63ac6573f 100644
--- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp
+++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_bench_qreadwritelock.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtCore>
#include <QTest>
diff --git a/tests/benchmarks/corelib/thread/qthreadpool/CMakeLists.txt b/tests/benchmarks/corelib/thread/qthreadpool/CMakeLists.txt
index 0d1f145e25..1353eaa2c4 100644
--- a/tests/benchmarks/corelib/thread/qthreadpool/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/qthreadpool/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qthreadpool Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qthreadpool
SOURCES
tst_bench_qthreadpool.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/thread/qthreadpool/tst_bench_qthreadpool.cpp b/tests/benchmarks/corelib/thread/qthreadpool/tst_bench_qthreadpool.cpp
index cc4ae3cfb2..e7e5636307 100644
--- a/tests/benchmarks/corelib/thread/qthreadpool/tst_bench_qthreadpool.cpp
+++ b/tests/benchmarks/corelib/thread/qthreadpool/tst_bench_qthreadpool.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2013 David Faure <david.faure@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtest.h>
#include <QtCore>
diff --git a/tests/benchmarks/corelib/thread/qthreadstorage/CMakeLists.txt b/tests/benchmarks/corelib/thread/qthreadstorage/CMakeLists.txt
index 7f5de4e9ab..916a2d8dee 100644
--- a/tests/benchmarks/corelib/thread/qthreadstorage/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/qthreadstorage/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qthreadstorage Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qthreadstorage
SOURCES
tst_bench_qthreadstorage.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/thread/qthreadstorage/tst_bench_qthreadstorage.cpp b/tests/benchmarks/corelib/thread/qthreadstorage/tst_bench_qthreadstorage.cpp
index 1361013833..47db215465 100644
--- a/tests/benchmarks/corelib/thread/qthreadstorage/tst_bench_qthreadstorage.cpp
+++ b/tests/benchmarks/corelib/thread/qthreadstorage/tst_bench_qthreadstorage.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qtest.h>
#include <QtCore>
@@ -64,6 +64,7 @@ void tst_QThreadStorage::get()
int *i = ts.localData();
count += *i;
}
+ QVERIFY(count > 0);
ts.setLocalData(0);
}
diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/CMakeLists.txt b/tests/benchmarks/corelib/thread/qwaitcondition/CMakeLists.txt
index 13814d7074..c7a15f9e8a 100644
--- a/tests/benchmarks/corelib/thread/qwaitcondition/CMakeLists.txt
+++ b/tests/benchmarks/corelib/thread/qwaitcondition/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qwaitcondition Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qwaitcondition
SOURCES
tst_bench_qwaitcondition.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp b/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp
index 2cdba3d07a..0abd53fc93 100644
--- a/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp
+++ b/tests/benchmarks/corelib/thread/qwaitcondition/tst_bench_qwaitcondition.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtCore>
#include <QTest>
diff --git a/tests/benchmarks/corelib/time/CMakeLists.txt b/tests/benchmarks/corelib/time/CMakeLists.txt
index 086650edb6..7c9de68486 100644
--- a/tests/benchmarks/corelib/time/CMakeLists.txt
+++ b/tests/benchmarks/corelib/time/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from time.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qdate)
add_subdirectory(qdatetime)
diff --git a/tests/benchmarks/corelib/time/qdate/CMakeLists.txt b/tests/benchmarks/corelib/time/qdate/CMakeLists.txt
index edc55463d8..e4ef5e3edc 100644
--- a/tests/benchmarks/corelib/time/qdate/CMakeLists.txt
+++ b/tests/benchmarks/corelib/time/qdate/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qdate.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qdate Binary:
@@ -7,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qdate
SOURCES
tst_bench_qdate.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp
index 448b941bb1..7dde3bf426 100644
--- a/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp
+++ b/tests/benchmarks/corelib/time/qdate/tst_bench_qdate.cpp
@@ -1,9 +1,10 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDate>
#include <QTest>
#include <QList>
+using namespace Qt::StringLiterals;
class tst_QDate : public QObject
{
@@ -33,6 +34,9 @@ private Q_SLOTS:
void addDays();
void addMonths();
void addYears();
+
+ void fromString_data();
+ void fromString();
};
QList<QDate> tst_QDate::daily(qint64 start, qint64 end)
@@ -184,5 +188,28 @@ void tst_QDate::addYears()
Q_UNUSED(store);
}
+void tst_QDate::fromString_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<int>("baseYear");
+
+ QTest::newRow("yyyyMMdd") << u"20240412"_s << u"yyyyMMdd"_s << 2000;
+ QTest::newRow("yyyy-MM-dd") << u"2024-04-12"_s << u"yyyy-MM-dd"_s << 2000;
+ QTest::newRow("YYYYMMDD") << u"20240412"_s << u"YYYYMMDD"_s << 2000; // Invalid, QTBUG-124465.
+}
+
+void tst_QDate::fromString()
+{
+ QFETCH(const QString, string);
+ QFETCH(const QString, format);
+ QFETCH(const int, baseYear);
+ QDate date;
+ QBENCHMARK {
+ date = QDate::fromString(string, format, baseYear);
+ }
+ Q_UNUSED(date);
+}
+
QTEST_MAIN(tst_QDate)
#include "tst_bench_qdate.moc"
diff --git a/tests/benchmarks/corelib/time/qdatetime/CMakeLists.txt b/tests/benchmarks/corelib/time/qdatetime/CMakeLists.txt
index a9546f3cad..14c0b9c730 100644
--- a/tests/benchmarks/corelib/time/qdatetime/CMakeLists.txt
+++ b/tests/benchmarks/corelib/time/qdatetime/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qdatetime Binary:
#####################################################################
@@ -5,6 +8,7 @@
qt_internal_add_benchmark(tst_bench_qdatetime
SOURCES
tst_bench_qdatetime.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
+ Qt::CorePrivate
)
diff --git a/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp b/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp
index ca648c051e..1c86eae009 100644
--- a/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp
+++ b/tests/benchmarks/corelib/time/qdatetime/tst_bench_qdatetime.cpp
@@ -1,18 +1,21 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDateTime>
#include <QTimeZone>
#include <QTest>
#include <QList>
#include <qdebug.h>
+#include <QtCore/private/qdatetime_p.h>
class tst_QDateTime : public QObject
{
Q_OBJECT
static QList<QDateTime> daily(qint64 start, qint64 end);
+#if QT_CONFIG(timezone)
static QList<QDateTime> norse(qint64 start, qint64 end);
+#endif
void decade_data();
private Q_SLOTS:
@@ -27,23 +30,33 @@ private Q_SLOTS:
void timeZoneAbbreviation();
void toMSecsSinceEpoch_data() { decade_data(); }
void toMSecsSinceEpoch();
+#if QT_CONFIG(timezone)
void toMSecsSinceEpochTz_data() { decade_data(); }
void toMSecsSinceEpochTz();
+#endif
void setDate();
void setTime();
+#if QT_DEPRECATED_SINCE(6, 9)
void setTimeSpec();
void setOffsetFromUtc();
+#endif
void setMSecsSinceEpoch();
+#if QT_CONFIG(timezone)
void setMSecsSinceEpochTz();
+#endif
void toString();
void toStringTextFormat();
void toStringIsoFormat();
void addDays();
+#if QT_CONFIG(timezone)
void addDaysTz();
- void addMSecs();
void addMSecsTz();
+#endif
+ void addMSecs();
+#if QT_DEPRECATED_SINCE(6, 9)
void toTimeSpec();
void toOffsetFromUtc();
+#endif
void daysTo();
void msecsTo();
void equivalent();
@@ -60,11 +73,12 @@ private Q_SLOTS:
void fromStringIso();
void fromMSecsSinceEpoch();
void fromMSecsSinceEpochUtc();
+#if QT_CONFIG(timezone)
void fromMSecsSinceEpochTz();
+#endif
};
-constexpr qint64 SECS_PER_DAY = 86400;
-constexpr qint64 MSECS_PER_DAY = 86400000;
+using namespace QtPrivate::DateTimeConstants;
constexpr qint64 JULIAN_DAY_1 = 1721426;
constexpr qint64 JULIAN_DAY_11 = 1725078;
constexpr qint64 JULIAN_DAY_1890 = 2411369;
@@ -98,7 +112,7 @@ QList<QDateTime> tst_QDateTime::daily(qint64 start, qint64 end)
list.append(QDateTime(QDate::fromJulianDay(jd).startOfDay()));
return list;
}
-
+#if QT_CONFIG(timezone)
QList<QDateTime> tst_QDateTime::norse(qint64 start, qint64 end)
{
const QTimeZone cet("Europe/Oslo");
@@ -108,7 +122,7 @@ QList<QDateTime> tst_QDateTime::norse(qint64 start, qint64 end)
list.append(QDateTime(QDate::fromJulianDay(jd).startOfDay(cet)));
return list;
}
-
+#endif
void tst_QDateTime::create()
{
QFETCH(const qint64, startJd);
@@ -195,7 +209,7 @@ void tst_QDateTime::toMSecsSinceEpoch()
test.toMSecsSinceEpoch();
}
}
-
+#if QT_CONFIG(timezone)
void tst_QDateTime::toMSecsSinceEpochTz()
{
QFETCH(const qint64, startJd);
@@ -209,7 +223,7 @@ void tst_QDateTime::toMSecsSinceEpochTz()
}
Q_UNUSED(result);
}
-
+#endif
void tst_QDateTime::setDate()
{
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
@@ -228,6 +242,9 @@ void tst_QDateTime::setTime()
}
}
+#if QT_DEPRECATED_SINCE(6, 9)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void tst_QDateTime::setTimeSpec()
{
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
@@ -245,6 +262,8 @@ void tst_QDateTime::setOffsetFromUtc()
test.setOffsetFromUtc(3600);
}
}
+QT_WARNING_POP
+#endif // 6.9 deprecation
void tst_QDateTime::setMSecsSinceEpoch()
{
@@ -255,7 +274,7 @@ void tst_QDateTime::setMSecsSinceEpoch()
test.setMSecsSinceEpoch(msecs);
}
}
-
+#if QT_CONFIG(timezone)
void tst_QDateTime::setMSecsSinceEpochTz()
{
const qint64 msecs = qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970 + 180) * MSECS_PER_DAY;
@@ -265,7 +284,7 @@ void tst_QDateTime::setMSecsSinceEpochTz()
test.setMSecsSinceEpoch(msecs);
}
}
-
+#endif
void tst_QDateTime::toString()
{
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2011);
@@ -303,7 +322,7 @@ void tst_QDateTime::addDays()
}
Q_UNUSED(next);
}
-
+#if QT_CONFIG(timezone)
void tst_QDateTime::addDaysTz()
{
const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
@@ -312,7 +331,7 @@ void tst_QDateTime::addDaysTz()
QDateTime result = test.addDays(1);
}
}
-
+#endif
void tst_QDateTime::addMSecs()
{
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
@@ -323,7 +342,7 @@ void tst_QDateTime::addMSecs()
}
Q_UNUSED(next);
}
-
+#if QT_CONFIG(timezone)
void tst_QDateTime::addMSecsTz()
{
const auto list = norse(JULIAN_DAY_2010, JULIAN_DAY_2020);
@@ -332,7 +351,10 @@ void tst_QDateTime::addMSecsTz()
QDateTime result = test.addMSecs(1);
}
}
-
+#endif
+#if QT_DEPRECATED_SINCE(6, 9)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void tst_QDateTime::toTimeSpec()
{
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
@@ -350,6 +372,8 @@ void tst_QDateTime::toOffsetFromUtc()
test.toOffsetFromUtc(3600);
}
}
+QT_WARNING_POP
+#endif
void tst_QDateTime::daysTo()
{
@@ -390,7 +414,7 @@ void tst_QDateTime::equivalentUtc()
{
bool result = false;
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
- qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC);
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, QTimeZone::UTC);
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
QBENCHMARK {
for (const QDateTime &test : list)
@@ -416,7 +440,7 @@ void tst_QDateTime::lessThanUtc()
{
bool result = false;
const QDateTime other = QDateTime::fromMSecsSinceEpoch(
- qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, Qt::UTC);
+ qint64(JULIAN_DAY_2010 - JULIAN_DAY_1970) * MSECS_PER_DAY, QTimeZone::UTC);
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
QBENCHMARK {
for (const QDateTime &test : list)
@@ -500,7 +524,7 @@ void tst_QDateTime::fromMSecsSinceEpoch()
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);
+ QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY);
}
}
@@ -510,10 +534,10 @@ void tst_QDateTime::fromMSecsSinceEpochUtc()
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);
+ QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, QTimeZone::UTC);
}
}
-
+#if QT_CONFIG(timezone)
void tst_QDateTime::fromMSecsSinceEpochTz()
{
const int start = JULIAN_DAY_2010 - JULIAN_DAY_1970;
@@ -524,6 +548,7 @@ void tst_QDateTime::fromMSecsSinceEpochTz()
QDateTime test = QDateTime::fromMSecsSinceEpoch(jd * MSECS_PER_DAY, cet);
}
}
+#endif
QTEST_MAIN(tst_QDateTime)
diff --git a/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt b/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt
index 99d8b7f044..f80b64be2d 100644
--- a/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt
+++ b/tests/benchmarks/corelib/time/qtimezone/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qtimezone Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qtimezone
SOURCES
tst_bench_qtimezone.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp
index 8e8ea4b55c..db8b910d98 100644
--- a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp
+++ b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp
@@ -1,6 +1,7 @@
+// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Crimson AS <info@crimson.no>
// Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTimeZone>
#include <QTest>
@@ -14,6 +15,7 @@ class tst_QTimeZone : public QObject
Q_OBJECT
private Q_SLOTS:
+#if QT_CONFIG(timezone)
void isTimeZoneIdAvailable();
void systemTimeZone();
void zoneByName_data();
@@ -24,31 +26,35 @@ private Q_SLOTS:
void transitionsForward();
void transitionsReverse_data() { transitionList_data(); }
void transitionsReverse();
+#endif
};
static QList<QByteArray> enoughZones()
{
#ifdef EXHAUSTIVE
- auto available = QTimeZone::availableTimeZoneIds();
- QList<QByteArray> result;
- result.reserve(available.size() + 1);
- for (conat auto &name : available)
- result << name;
+ QList<QByteArray> result = QTimeZone::availableTimeZoneIds();
#else
- QList<QByteArray> result { QByteArray("UTC"),
- // Those named overtly in tst_QDateTime:
- QByteArray("Europe/Oslo"), QByteArray("America/Vancouver"),
- QByteArray("Europe/Berlin"), QByteArray("America/Sao_Paulo"),
- QByteArray("Pacific/Auckland"), QByteArray("Australia/Eucla"),
- QByteArray("Asia/Kathmandu"), QByteArray("Pacific/Kiritimati"),
- QByteArray("Pacific/Apia"), QByteArray("UTC+12:00"),
- QByteArray("Australia/Sydney"), QByteArray("Asia/Singapore"),
- QByteArray("Australia/Brisbane") };
+ QList<QByteArray> result {
+ QByteArray("UTC"),
+ // Those named overtly in tst_QDateTime - special cases first:
+ QByteArray("UTC-02:00"), QByteArray("UTC+02:00"), QByteArray("UTC+12:00"),
+ QByteArray("Etc/GMT+3"), QByteArray("GMT-2"), QByteArray("GMT"),
+ // ... then ordinary names in alphabetic order:
+ QByteArray("America/New_York"), QByteArray("America/Sao_Paulo"),
+ QByteArray("America/Vancouver"),
+ QByteArray("Asia/Kathmandu"), QByteArray("Asia/Singapore"),
+ QByteArray("Australia/Brisbane"), QByteArray("Australia/Eucla"),
+ QByteArray("Australia/Sydney"),
+ QByteArray("Europe/Berlin"), QByteArray("Europe/Helsinki"),
+ QByteArray("Europe/Rome"), QByteArray("Europe/Oslo"),
+ QByteArray("Pacific/Apia"), QByteArray("Pacific/Auckland"),
+ QByteArray("Pacific/Kiritimati")
+ };
#endif
result << QByteArray("Vulcan/ShiKahr"); // invalid: also worth testing
return result;
}
-
+#if QT_CONFIG(timezone)
void tst_QTimeZone::isTimeZoneIdAvailable()
{
const QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
@@ -64,7 +70,6 @@ void tst_QTimeZone::systemTimeZone()
QTimeZone::systemTimeZone();
}
}
-
void tst_QTimeZone::zoneByName_data()
{
QTest::addColumn<QByteArray>("name");
@@ -101,9 +106,9 @@ void tst_QTimeZone::transitionList()
{
QFETCH(QByteArray, name);
const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name);
- const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date
+ const QDateTime early = QDate(1625, 6, 8).startOfDay(QTimeZone::UTC); // Cassini's birth date
const QDateTime late // End of 32-bit signed time_t
- = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), Qt::UTC);
+ = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), QTimeZone::UTC);
QTimeZone::OffsetDataList seq;
QBENCHMARK {
seq = zone.transitions(early, late);
@@ -115,7 +120,7 @@ void tst_QTimeZone::transitionsForward()
{
QFETCH(QByteArray, name);
const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name);
- const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date
+ const QDateTime early = QDate(1625, 6, 8).startOfDay(QTimeZone::UTC); // Cassini's birth date
QBENCHMARK {
QTimeZone::OffsetData tran = zone.nextTransition(early);
while (tran.atUtc.isValid())
@@ -128,13 +133,14 @@ void tst_QTimeZone::transitionsReverse()
QFETCH(QByteArray, name);
const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name);
const QDateTime late // End of 32-bit signed time_t
- = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), Qt::UTC);
+ = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), QTimeZone::UTC);
QBENCHMARK {
QTimeZone::OffsetData tran = zone.previousTransition(late);
while (tran.atUtc.isValid())
tran = zone.previousTransition(tran.atUtc);
}
}
+#endif
QTEST_MAIN(tst_QTimeZone)
diff --git a/tests/benchmarks/corelib/tools/CMakeLists.txt b/tests/benchmarks/corelib/tools/CMakeLists.txt
index 25cc02ad1d..b46eac4165 100644
--- a/tests/benchmarks/corelib/tools/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
add_subdirectory(containers-associative)
add_subdirectory(containers-sequential)
add_subdirectory(qcontiguouscache)
diff --git a/tests/benchmarks/corelib/tools/containers-associative/CMakeLists.txt b/tests/benchmarks/corelib/tools/containers-associative/CMakeLists.txt
index 50bf8a0c0f..7036fa96b7 100644
--- a/tests/benchmarks/corelib/tools/containers-associative/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/containers-associative/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_containers_associative Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_containers_associative
SOURCES
tst_bench_containers_associative.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/containers-associative/tst_bench_containers_associative.cpp b/tests/benchmarks/corelib/tools/containers-associative/tst_bench_containers_associative.cpp
index ee711abf85..a5618cfcaf 100644
--- a/tests/benchmarks/corelib/tools/containers-associative/tst_bench_containers_associative.cpp
+++ b/tests/benchmarks/corelib/tools/containers-associative/tst_bench_containers_associative.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QString>
#include <QMap>
#include <QHash>
diff --git a/tests/benchmarks/corelib/tools/containers-sequential/CMakeLists.txt b/tests/benchmarks/corelib/tools/containers-sequential/CMakeLists.txt
index 2e6d26e343..d24f26e664 100644
--- a/tests/benchmarks/corelib/tools/containers-sequential/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/containers-sequential/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_containers-sequential Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_containers_sequential
SOURCES
tst_bench_containers_sequential.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/containers-sequential/tst_bench_containers_sequential.cpp b/tests/benchmarks/corelib/tools/containers-sequential/tst_bench_containers_sequential.cpp
index 76d93cd85c..78c8016664 100644
--- a/tests/benchmarks/corelib/tools/containers-sequential/tst_bench_containers_sequential.cpp
+++ b/tests/benchmarks/corelib/tools/containers-sequential/tst_bench_containers_sequential.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// This file contains benchmarks for comparing QList against std::vector
#include <QtCore>
@@ -65,7 +65,7 @@ class UseCases_stdvector : public UseCases<T>
void insert(int size) override
{
std::vector<T> v;
- T t;
+ T t = {};
QBENCHMARK {
for (int i = 0; i < size; ++i)
v.push_back(t);
@@ -76,7 +76,7 @@ class UseCases_stdvector : public UseCases<T>
{
std::vector<T> v;
- T t;
+ T t = {};
for (int i = 0; i < size; ++i)
v.push_back(t);
diff --git a/tests/benchmarks/corelib/tools/qcontiguouscache/CMakeLists.txt b/tests/benchmarks/corelib/tools/qcontiguouscache/CMakeLists.txt
index 29366ecf36..9a68212fc0 100644
--- a/tests/benchmarks/corelib/tools/qcontiguouscache/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qcontiguouscache/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qcontiguouscache Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qcontiguouscache
SOURCES
tst_bench_qcontiguouscache.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qcontiguouscache/tst_bench_qcontiguouscache.cpp b/tests/benchmarks/corelib/tools/qcontiguouscache/tst_bench_qcontiguouscache.cpp
index e23e762154..ae2cf471b0 100644
--- a/tests/benchmarks/corelib/tools/qcontiguouscache/tst_bench_qcontiguouscache.cpp
+++ b/tests/benchmarks/corelib/tools/qcontiguouscache/tst_bench_qcontiguouscache.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
#include <QTest>
diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/CMakeLists.txt b/tests/benchmarks/corelib/tools/qcryptographichash/CMakeLists.txt
index e9d539eb1a..b69b884f7d 100644
--- a/tests/benchmarks/corelib/tools/qcryptographichash/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qcryptographichash/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qcryptographichash Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qcryptographichash
SOURCES
tst_bench_qcryptographichash.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp
index 719ba7a8c1..9f2d1c57f2 100644
--- a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp
+++ b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp
@@ -1,13 +1,19 @@
+// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2017 Intel Corporation.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QByteArray>
#include <QCryptographicHash>
#include <QFile>
+#include <QMetaEnum>
+#include <QMessageAuthenticationCode>
#include <QRandomGenerator>
#include <QString>
#include <QTest>
+#include <qxpfunctional.h>
+#include <numeric>
+
#include <time.h>
class tst_QCryptographicHash : public QObject
@@ -15,6 +21,8 @@ class tst_QCryptographicHash : public QObject
Q_OBJECT
QByteArray blockOfData;
+ using Algorithm = QCryptographicHash::Algorithm;
+
public:
tst_QCryptographicHash();
@@ -25,63 +33,24 @@ private Q_SLOTS:
void addData();
void addDataChunked_data() { hash_data(); }
void addDataChunked();
+
+ // QMessageAuthenticationCode:
+ void hmac_hash_data() { hash_data(); }
+ void hmac_hash();
+ void hmac_addData_data() { hash_data(); }
+ void hmac_addData();
+ void hmac_setKey_data();
+ void hmac_setKey();
};
-const int MaxCryptoAlgorithm = QCryptographicHash::Sha3_512;
const int MaxBlockSize = 65536;
-const char *algoname(int i)
+static void for_each_algorithm(qxp::function_ref<void(QCryptographicHash::Algorithm, const char*) const> f)
{
- switch (QCryptographicHash::Algorithm(i)) {
- case QCryptographicHash::Md4:
- return "md4-";
- case QCryptographicHash::Md5:
- return "md5-";
- case QCryptographicHash::Sha1:
- return "sha1-";
- case QCryptographicHash::Sha224:
- return "sha2_224-";
- case QCryptographicHash::Sha256:
- return "sha2_256-";
- case QCryptographicHash::Sha384:
- return "sha2_384-";
- case QCryptographicHash::Sha512:
- return "sha2_512-";
- case QCryptographicHash::Sha3_224:
- return "sha3_224-";
- case QCryptographicHash::Sha3_256:
- return "sha3_256-";
- case QCryptographicHash::Sha3_384:
- return "sha3_384-";
- case QCryptographicHash::Sha3_512:
- return "sha3_512-";
- case QCryptographicHash::Keccak_224:
- return "keccak_224-";
- case QCryptographicHash::Keccak_256:
- return "keccak_256-";
- case QCryptographicHash::Keccak_384:
- return "keccak_384-";
- case QCryptographicHash::Keccak_512:
- return "keccak_512-";
- case QCryptographicHash::Blake2b_160:
- return "blake2b_160-";
- case QCryptographicHash::Blake2b_256:
- return "blake2b_256-";
- case QCryptographicHash::Blake2b_384:
- return "blake2b_384-";
- case QCryptographicHash::Blake2b_512:
- return "blake2b_512-";
- case QCryptographicHash::Blake2s_128:
- return "blake2s_128-";
- case QCryptographicHash::Blake2s_160:
- return "blake2s_160-";
- case QCryptographicHash::Blake2s_224:
- return "blake2s_224-";
- case QCryptographicHash::Blake2s_256:
- return "blake2s_256-";
- }
- Q_UNREACHABLE();
- return nullptr;
+ using A = QCryptographicHash::Algorithm;
+ static const auto metaEnum = QMetaEnum::fromType<A>();
+ for (int i = 0, value = metaEnum.value(i); value != -1; value = metaEnum.value(++i))
+ f(A(value), metaEnum.key(i));
}
tst_QCryptographicHash::tst_QCryptographicHash()
@@ -101,7 +70,7 @@ tst_QCryptographicHash::tst_QCryptographicHash()
void tst_QCryptographicHash::hash_data()
{
- QTest::addColumn<int>("algorithm");
+ QTest::addColumn<Algorithm>("algo");
QTest::addColumn<QByteArray>("data");
static const int datasizes[] = { 0, 1, 64, 65, 512, 4095, 4096, 4097, 65536 };
@@ -109,42 +78,56 @@ void tst_QCryptographicHash::hash_data()
Q_ASSERT(datasizes[i] < MaxBlockSize);
QByteArray data = QByteArray::fromRawData(blockOfData.constData(), datasizes[i]);
- for (int algo = QCryptographicHash::Md4; algo <= MaxCryptoAlgorithm; ++algo)
- QTest::newRow(algoname(algo) + QByteArray::number(datasizes[i])) << algo << data;
+ for_each_algorithm([&] (Algorithm algo, const char *name) {
+ if (algo == Algorithm::NumAlgorithms)
+ return;
+ QTest::addRow("%s-%d", name, datasizes[i]) << algo << data;
+ });
}
}
+#define SKIP_IF_NOT_SUPPORTED(algo) do { \
+ if (!QCryptographicHash::supportsAlgorithm(algo)) \
+ QSKIP("This algorithm is not supported in this configuration"); \
+ } while (false) \
+ /* end */
+
void tst_QCryptographicHash::hash()
{
- QFETCH(int, algorithm);
+ QFETCH(const Algorithm, algo);
QFETCH(QByteArray, data);
- QCryptographicHash::Algorithm algo = QCryptographicHash::Algorithm(algorithm);
+ SKIP_IF_NOT_SUPPORTED(algo);
+
QBENCHMARK {
- QCryptographicHash::hash(data, algo);
+ [[maybe_unused]]
+ auto r = QCryptographicHash::hash(data, algo);
}
}
void tst_QCryptographicHash::addData()
{
- QFETCH(int, algorithm);
+ QFETCH(const Algorithm, algo);
QFETCH(QByteArray, data);
- QCryptographicHash::Algorithm algo = QCryptographicHash::Algorithm(algorithm);
+ SKIP_IF_NOT_SUPPORTED(algo);
+
QCryptographicHash hash(algo);
QBENCHMARK {
hash.reset();
hash.addData(data);
- hash.result();
+ [[maybe_unused]]
+ auto r = hash.resultView();
}
}
void tst_QCryptographicHash::addDataChunked()
{
- QFETCH(int, algorithm);
+ QFETCH(const Algorithm, algo);
QFETCH(QByteArray, data);
- QCryptographicHash::Algorithm algo = QCryptographicHash::Algorithm(algorithm);
+ SKIP_IF_NOT_SUPPORTED(algo);
+
QCryptographicHash hash(algo);
QBENCHMARK {
hash.reset();
@@ -154,10 +137,87 @@ void tst_QCryptographicHash::addDataChunked()
hash.addData({data.constData() + 64 * i, 64});
hash.addData({data.constData() + data.size() / 64 * 64, data.size() % 64});
- hash.result();
+ [[maybe_unused]]
+ auto r = hash.resultView();
+ }
+}
+
+static QByteArray hmacKey() {
+ static QByteArray key = [] {
+ QByteArray result(277, Qt::Uninitialized);
+ std::iota(result.begin(), result.end(), uchar(0)); // uchar so wraps after UCHAR_MAX
+ return result;
+ }();
+ return key;
+}
+
+void tst_QCryptographicHash::hmac_hash()
+{
+ QFETCH(const Algorithm, algo);
+ QFETCH(const QByteArray, data);
+
+ SKIP_IF_NOT_SUPPORTED(algo);
+
+ const auto key = hmacKey();
+ QBENCHMARK {
+ [[maybe_unused]]
+ auto r = QMessageAuthenticationCode::hash(data, key, algo);
+ }
+}
+
+void tst_QCryptographicHash::hmac_addData()
+{
+ QFETCH(const Algorithm, algo);
+ QFETCH(const QByteArray, data);
+
+ SKIP_IF_NOT_SUPPORTED(algo);
+
+ const auto key = hmacKey();
+ QMessageAuthenticationCode mac(algo, key);
+ QBENCHMARK {
+ mac.reset();
+ mac.addData(data);
+ [[maybe_unused]]
+ auto r = mac.resultView();
+ }
+}
+
+void tst_QCryptographicHash::hmac_setKey_data()
+{
+ QTest::addColumn<Algorithm>("algo");
+ for_each_algorithm([] (Algorithm algo, const char *name) {
+ if (algo == Algorithm::NumAlgorithms)
+ return;
+ QTest::addRow("%s", name) << algo;
+ });
+}
+
+void tst_QCryptographicHash::hmac_setKey()
+{
+ QFETCH(const Algorithm, algo);
+
+ SKIP_IF_NOT_SUPPORTED(algo);
+
+ const QByteArrayList keys = [] {
+ QByteArrayList result;
+ const auto fullKey = hmacKey();
+ result.reserve(fullKey.size());
+ for (auto i = fullKey.size(); i > 0; --i)
+ result.push_back(fullKey.sliced(i));
+ return result;
+ }();
+
+ QMessageAuthenticationCode mac(algo);
+ QBENCHMARK {
+ for (const auto &key : keys) {
+ mac.setKey(key);
+ mac.addData("abc", 3); // avoid lazy setKey()
+ }
}
}
+#undef SKIP_IF_NOT_SUPPORTED
+
QTEST_APPLESS_MAIN(tst_QCryptographicHash)
#include "tst_bench_qcryptographichash.moc"
diff --git a/tests/benchmarks/corelib/tools/qhash/CMakeLists.txt b/tests/benchmarks/corelib/tools/qhash/CMakeLists.txt
index 437ea285e8..9002cc0723 100644
--- a/tests/benchmarks/corelib/tools/qhash/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qhash/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qhash Binary:
#####################################################################
@@ -6,8 +9,10 @@ qt_internal_add_benchmark(tst_bench_qhash
SOURCES
tst_bench_qhash.cpp
outofline.cpp
+ NO_PCH_SOURCES
+ tst_bench_qhash.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qhash/outofline.cpp b/tests/benchmarks/corelib/tools/qhash/outofline.cpp
index c8adc73da4..5b16c36ffb 100644
--- a/tests/benchmarks/corelib/tools/qhash/outofline.cpp
+++ b/tests/benchmarks/corelib/tools/qhash/outofline.cpp
@@ -1,13 +1,13 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "tst_bench_qhash.h"
QT_BEGIN_NAMESPACE
-uint qHash(const Qt4String &str)
+size_t qHash(const Qt4String &str, size_t /* never used */)
{
- int n = str.length();
+ qsizetype n = str.size();
const QChar *p = str.unicode();
uint h = 0;
@@ -19,11 +19,11 @@ uint qHash(const Qt4String &str)
return h;
}
-uint qHash(const Qt50String &key, uint seed)
+size_t qHash(const Qt50String &key, size_t seed)
{
const QChar *p = key.unicode();
- int len = key.size();
- uint h = seed;
+ qsizetype len = key.size();
+ size_t h = seed;
for (int i = 0; i < len; ++i)
h = 31 * h + p[i].unicode();
return h;
@@ -40,10 +40,10 @@ uint qHash(const Qt50String &key, uint seed)
// Still, we can avoid writing the multiplication as "(h << 5) - h"
// -- the compiler will turn it into a shift and an addition anyway
// (for instance, gcc 4.4 does that even at -O0).
-uint qHash(const JavaString &str)
+size_t qHash(const JavaString &str, size_t /* never used */)
{
- const unsigned short *p = (unsigned short *)str.constData();
- const int len = str.size();
+ const auto *p = reinterpret_cast<const char16_t *>(str.constData());
+ const qsizetype len = str.size();
uint h = 0;
diff --git a/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp b/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp
index ca48763538..1a62a48437 100644
--- a/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp
+++ b/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// Copyright (C) 2016 Intel Corporation.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "tst_bench_qhash.h"
@@ -11,6 +13,8 @@
#include <QUuid>
#include <QTest>
+static constexpr quint64 RandomSeed32 = 1045982819;
+static constexpr quint64 RandomSeed64 = QtPrivate::QHashCombine{}(RandomSeed32, RandomSeed32);
class tst_QHash : public QObject
{
@@ -29,6 +33,8 @@ private slots:
void hashing_current_data() { data(); }
void hashing_current() { hashing_template<QString>(); }
+ void hashing_qbytearray_data() { data(); }
+ void hashing_qbytearray() { hashing_template<QByteArray>(); }
void hashing_qt50_data() { data(); }
void hashing_qt50() { hashing_template<Qt50String>(); }
void hashing_qt4_data() { data(); }
@@ -36,15 +42,25 @@ private slots:
void hashing_javaString_data() { data(); }
void hashing_javaString() { hashing_template<JavaString>(); }
+ void hashing_nonzero_current_data() { data(); }
+ void hashing_nonzero_current() { hashing_nonzero_template<QString>(); }
+ void hashing_nonzero_qbytearray_data() { data(); }
+ void hashing_nonzero_qbytearray() { hashing_nonzero_template<QByteArray>(); }
+ void hashing_nonzero_qlatin1string_data() { data(); }
+ void hashing_nonzero_qlatin1string() { hashing_nonzero_template<OwningLatin1String>(); }
+
private:
void data();
template <typename String> void qhash_template();
- template <typename String> void hashing_template();
+ template <typename String, size_t Seed = 0> void hashing_template();
+ template <typename String> void hashing_nonzero_template()
+ { hashing_template<String, size_t(RandomSeed64)>(); }
QStringList smallFilePaths;
QStringList uuids;
QStringList dict;
QStringList numbers;
+ QStringList longstrings;
};
///////////////////// QHash /////////////////////
@@ -53,6 +69,8 @@ private:
void tst_QHash::initTestCase()
{
+ QHashSeed::setDeterministicGlobalSeed();
+
// small list of strings (that happen to look like file paths produced long
// ago by cd ../.. && find . -print, but that's irrelevant).
QFile smallPathsData(QFINDTESTDATA("paths_small_data.txt"));
@@ -64,10 +82,12 @@ void tst_QHash::initTestCase()
// guaranteed to be completely random, generated by http://xkcd.com/221/
QUuid ns = QUuid("{f43d2ef3-2fe9-4563-a6f5-5a0100c2d699}");
uuids.reserve(smallFilePaths.size());
+ longstrings.reserve(smallFilePaths.size());
foreach (const QString &path, smallFilePaths)
uuids.append(QUuid::createUuidV5(ns, path).toString());
-
+ for (qsizetype i = 0; i < uuids.size(); ++i)
+ longstrings.append(uuids.at(i).repeated(8));
// lots of strings with alphabetical characters, vaguely reminiscent of
// a dictionary.
@@ -85,7 +105,7 @@ void tst_QHash::initTestCase()
QByteArray id("AAAAAAA");
if (dict.isEmpty()) {
- for (int i = id.length() - 1; i > 0;) {
+ for (int i = id.size() - 1; i > 0;) {
dict.append(id);
char c = id.at(i);
id[i] = ++c;
@@ -108,6 +128,7 @@ void tst_QHash::data()
QTest::addColumn<QStringList>("items");
QTest::newRow("paths-small") << smallFilePaths;
QTest::newRow("uuids-list") << uuids;
+ QTest::newRow("longstrings-list") << longstrings;
QTest::newRow("dictionary") << dict;
QTest::newRow("numbers") << numbers;
}
@@ -128,19 +149,30 @@ template <typename String> void tst_QHash::qhash_template()
}
}
-template <typename String> void tst_QHash::hashing_template()
+template <typename String, size_t Seed> void tst_QHash::hashing_template()
{
// just the hashing function
QFETCH(QStringList, items);
QList<String> realitems;
realitems.reserve(items.size());
- foreach (const QString &s, items)
- realitems.append(s);
+ foreach (const QString &s, items) {
+ if constexpr (std::is_same_v<QString::value_type, typename String::value_type>) {
+ realitems.append(s);
+ } else if constexpr (sizeof(typename String::value_type) == 1) {
+ realitems.append(String(s.toLatin1()));
+ }
+ }
QBENCHMARK {
- for (int i = 0, n = realitems.size(); i != n; ++i)
- (void)qHash(realitems.at(i));
+ for (int i = 0, n = realitems.size(); i != n; ++i) {
+ volatile size_t h = qHash(realitems.at(i), Seed);
+ (void)h;
+#ifdef Q_CC_GNU
+ // "use" h
+ asm ("" : "+r" (h));
+#endif
+ }
}
}
diff --git a/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.h b/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.h
index b566cb82db..501b4a8b7f 100644
--- a/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.h
+++ b/tests/benchmarks/corelib/tools/qhash/tst_bench_qhash.h
@@ -1,8 +1,20 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#include <QHashFunctions>
#include <QString>
+struct OwningLatin1String : QByteArray
+{
+ OwningLatin1String() = default;
+ OwningLatin1String(const QByteArray &a) : QByteArray(a) {}
+ OwningLatin1String(QByteArray &&a) : QByteArray(std::move(a)) {}
+};
+QT_BEGIN_NAMESPACE
+inline size_t qHash(const OwningLatin1String &s, size_t seed = 0)
+{ return qHash(QLatin1StringView(s), seed); }
+QT_END_NAMESPACE
+
struct Qt4String : QString
{
Qt4String() {}
@@ -10,7 +22,7 @@ struct Qt4String : QString
};
QT_BEGIN_NAMESPACE
-uint qHash(const Qt4String &);
+size_t qHash(const Qt4String &, size_t = 0);
QT_END_NAMESPACE
struct Qt50String : QString
@@ -20,7 +32,7 @@ struct Qt50String : QString
};
QT_BEGIN_NAMESPACE
-uint qHash(const Qt50String &, uint seed = 0);
+size_t qHash(const Qt50String &, size_t seed = 0);
QT_END_NAMESPACE
@@ -31,6 +43,6 @@ struct JavaString : QString
};
QT_BEGIN_NAMESPACE
-uint qHash(const JavaString &);
+size_t qHash(const JavaString &, size_t = 0);
QT_END_NAMESPACE
diff --git a/tests/benchmarks/corelib/tools/qlist/CMakeLists.txt b/tests/benchmarks/corelib/tools/qlist/CMakeLists.txt
index 6c9a96399f..dabfe08122 100644
--- a/tests/benchmarks/corelib/tools/qlist/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qlist/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qlist Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qlist
SOURCES
tst_bench_qlist.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qlist/tst_bench_qlist.cpp b/tests/benchmarks/corelib/tools/qlist/tst_bench_qlist.cpp
index 7c014e7bc7..24691d1f71 100644
--- a/tests/benchmarks/corelib/tools/qlist/tst_bench_qlist.cpp
+++ b/tests/benchmarks/corelib/tools/qlist/tst_bench_qlist.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QList>
#include <QTest>
diff --git a/tests/benchmarks/corelib/tools/qmap/CMakeLists.txt b/tests/benchmarks/corelib/tools/qmap/CMakeLists.txt
index f4b389ad08..4dc3dbb258 100644
--- a/tests/benchmarks/corelib/tools/qmap/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qmap/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmap.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qmap Binary:
@@ -9,6 +10,6 @@ qt_internal_add_benchmark(tst_bench_qmap
tst_bench_qmap.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp b/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp
index f44d58edc5..db3c4fc7a2 100644
--- a/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp
+++ b/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QMap>
diff --git a/tests/benchmarks/corelib/tools/qrect/CMakeLists.txt b/tests/benchmarks/corelib/tools/qrect/CMakeLists.txt
index e3ce41f7be..e28ca82c74 100644
--- a/tests/benchmarks/corelib/tools/qrect/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qrect/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qrect Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qrect
SOURCES
tst_bench_qrect.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qrect/tst_bench_qrect.cpp b/tests/benchmarks/corelib/tools/qrect/tst_bench_qrect.cpp
index dbf4c2db6c..0ba9e15963 100644
--- a/tests/benchmarks/corelib/tools/qrect/tst_bench_qrect.cpp
+++ b/tests/benchmarks/corelib/tools/qrect/tst_bench_qrect.cpp
@@ -1,7 +1,9 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// This file contains benchmarks for QRect/QRectF functions.
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
+
#include <QDebug>
#include <qtest.h>
diff --git a/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt b/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt
index 23a2c990de..322fbbb83c 100644
--- a/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qringbuffer Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qringbuffer
SOURCES
tst_bench_qringbuffer.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp b/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp
index 7acb0005ef..f352cd56a9 100644
--- a/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp
+++ b/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <private/qringbuffer_p.h>
#include <QByteArray>
diff --git a/tests/benchmarks/corelib/tools/qset/CMakeLists.txt b/tests/benchmarks/corelib/tools/qset/CMakeLists.txt
index 844226c833..7bbed20106 100644
--- a/tests/benchmarks/corelib/tools/qset/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qset/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qset Binary:
#####################################################################
@@ -5,6 +8,6 @@
qt_internal_add_benchmark(tst_bench_qset
SOURCES
tst_bench_qset.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qset/tst_bench_qset.cpp b/tests/benchmarks/corelib/tools/qset/tst_bench_qset.cpp
index 9ac1a0449f..5bbec05aab 100644
--- a/tests/benchmarks/corelib/tools/qset/tst_bench_qset.cpp
+++ b/tests/benchmarks/corelib/tools/qset/tst_bench_qset.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QSet>
#include <QTest>
@@ -9,12 +9,22 @@ class tst_QSet : public QObject
Q_OBJECT
private slots:
+ void initTestCase();
void intersect_int_data();
void intersect_int();
void intersect_complexType_data();
void intersect_complexType();
+ void unite_int_data();
+ void unite_int();
+ void contains_then_insert_int_data();
+ void contains_then_insert_int();
};
+void tst_QSet::initTestCase()
+{
+ QHashSeed::setDeterministicGlobalSeed();
+}
+
void tst_QSet::intersect_int_data()
{
QTest::addColumn<int>("lhsSize");
@@ -98,6 +108,70 @@ void tst_QSet::intersect_complexType()
}
}
+void tst_QSet::unite_int_data()
+{
+ QTest::addColumn<int>("lhsSize");
+ QTest::addColumn<int>("rhsSize");
+ QTest::addColumn<int>("overlap");
+
+ QTest::newRow("1000000.unite(1000) - 0 overlap") << 1000000 << 1000 << 0;
+ QTest::newRow("1000000.unite(1000) - 100 overlap") << 1000000 << 1000 << 100;
+ QTest::newRow("1000000.unite(1000) - 1000 overlap") << 1000000 << 1000 << 1000;
+ QTest::newRow("1000.unite(1000000) - 0 overlap") << 1000 << 1000000 << 0;
+ QTest::newRow("1000.unite(1000000) - 100 overlap") << 1000 << 1000000 << 100;
+ QTest::newRow("1000.unite(1000000) - 1000 overlap") << 1000 << 1000000 << 1000;
+}
+
+auto build_sets(int lhsSize, int rhsSize, int overlap)
+{
+ QSet<int> lhs;
+ for (int i = 0; i < lhsSize; ++i)
+ lhs.insert(i);
+
+ QSet<int> rhs;
+ for (int i = lhsSize - overlap; i < rhsSize + lhsSize - overlap; ++i)
+ rhs.insert(i);
+
+ return std::make_pair(lhs, rhs);
+}
+
+void tst_QSet::unite_int()
+{
+ QFETCH(int, lhsSize);
+ QFETCH(int, rhsSize);
+ QFETCH(int, overlap);
+
+ auto [lhs, rhs] = build_sets(lhsSize, rhsSize, overlap);
+
+ QBENCHMARK {
+ QSet united = QSet(lhs).unite(rhs);
+ QCOMPARE(united.size(), lhsSize + rhsSize - overlap);
+ }
+}
+
+void tst_QSet::contains_then_insert_int_data()
+{
+ unite_int_data();
+}
+
+void tst_QSet::contains_then_insert_int()
+{
+ QFETCH(int, lhsSize);
+ QFETCH(int, rhsSize);
+ QFETCH(int, overlap);
+
+ auto [lhs, rhs] = build_sets(lhsSize, rhsSize, overlap);
+
+ QBENCHMARK {
+ QSet copy(lhs);
+ for (auto i : rhs) {
+ if (!copy.contains(i))
+ copy.insert(i);
+ }
+ QCOMPARE(copy.size(), lhsSize + rhsSize - overlap);
+ }
+}
+
QTEST_MAIN(tst_QSet)
#include "tst_bench_qset.moc"
diff --git a/tests/benchmarks/corelib/tools/qsharedpointer/CMakeLists.txt b/tests/benchmarks/corelib/tools/qsharedpointer/CMakeLists.txt
index 5103fc3229..6adf1f2e4e 100644
--- a/tests/benchmarks/corelib/tools/qsharedpointer/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qsharedpointer/CMakeLists.txt
@@ -1,9 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_benchmark(tst_bench_shared_ptr
SOURCES
tst_bench_shared_ptr.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp b/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp
index b00bef96d4..6197863601 100644
--- a/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp
+++ b/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
#include <QScopeGuard>
diff --git a/tests/benchmarks/corelib/tools/qstack/CMakeLists.txt b/tests/benchmarks/corelib/tools/qstack/CMakeLists.txt
index 9cd09a0699..e5ae510521 100644
--- a/tests/benchmarks/corelib/tools/qstack/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qstack/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## tst_bench_qstack Binary:
#####################################################################
@@ -5,7 +8,7 @@
qt_internal_add_benchmark(tst_bench_qstack
SOURCES
tst_bench_qstack.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qstack/tst_bench_qstack.cpp b/tests/benchmarks/corelib/tools/qstack/tst_bench_qstack.cpp
index 468fb4b820..e0c8cda18c 100644
--- a/tests/benchmarks/corelib/tools/qstack/tst_bench_qstack.cpp
+++ b/tests/benchmarks/corelib/tools/qstack/tst_bench_qstack.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2015 Robin Burchell <robin.burchell@viroteck.net>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QStack>
#include <QDebug>
diff --git a/tests/benchmarks/corelib/tools/qvector/CMakeLists.txt b/tests/benchmarks/corelib/tools/qvector/CMakeLists.txt
index 37510cce42..df2fc8ec6a 100644
--- a/tests/benchmarks/corelib/tools/qvector/CMakeLists.txt
+++ b/tests/benchmarks/corelib/tools/qvector/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qvector.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qvector Binary:
@@ -10,7 +11,7 @@ qt_internal_add_benchmark(tst_bench_qvector
outofline.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
diff --git a/tests/benchmarks/corelib/tools/qvector/outofline.cpp b/tests/benchmarks/corelib/tools/qvector/outofline.cpp
index e2421e14e0..eb4756f710 100644
--- a/tests/benchmarks/corelib/tools/qvector/outofline.cpp
+++ b/tests/benchmarks/corelib/tools/qvector/outofline.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QList>
#include "qrawvector.h"
diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
index 606e3268e3..9e68b81285 100644
--- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h
+++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QRAWVECTOR_H
#define QRAWVECTOR_H
diff --git a/tests/benchmarks/corelib/tools/qvector/tst_bench_qvector.cpp b/tests/benchmarks/corelib/tools/qvector/tst_bench_qvector.cpp
index 2e2036110d..0486beed4e 100644
--- a/tests/benchmarks/corelib/tools/qvector/tst_bench_qvector.cpp
+++ b/tests/benchmarks/corelib/tools/qvector/tst_bench_qvector.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QVector>
#include <QDebug>