summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib/io')
-rw-r--r--tests/benchmarks/corelib/io/CMakeLists.txt8
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp (renamed from tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp)153
-rw-r--r--tests/benchmarks/corelib/io/qdir/CMakeLists.txt5
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt2
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt21
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp (renamed from tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp)78
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.qrc (renamed from tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc)0
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt7
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp31
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h29
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp (renamed from tests/benchmarks/corelib/io/qdiriterator/main.cpp)131
-rw-r--r--tests/benchmarks/corelib/io/qfile/CMakeLists.txt8
-rw-r--r--tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp51
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp (renamed from tests/benchmarks/corelib/io/qfileinfo/main.cpp)55
-rw-r--r--tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp (renamed from tests/benchmarks/corelib/io/qiodevice/main.cpp)42
-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.txt5
-rw-r--r--tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp19
-rw-r--r--tests/benchmarks/corelib/io/qprocess/testProcessLoopback/main.cpp44
-rw-r--r--tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp33
-rw-r--r--tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/io/qtemporaryfile/main.cpp90
-rw-r--r--tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp64
-rw-r--r--tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt10
-rw-r--r--tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp (renamed from tests/benchmarks/corelib/io/qtextstream/main.cpp)39
-rw-r--r--tests/benchmarks/corelib/io/qurl/CMakeLists.txt14
-rw-r--r--tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp (renamed from tests/benchmarks/corelib/io/qurl/main.cpp)75
31 files changed, 389 insertions, 673 deletions
diff --git a/tests/benchmarks/corelib/io/CMakeLists.txt b/tests/benchmarks/corelib/io/CMakeLists.txt
index 3419c4a28c..e9bf2292c0 100644
--- a/tests/benchmarks/corelib/io/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/CMakeLists.txt
@@ -1,12 +1,14 @@
-# Generated from io.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qdir)
add_subdirectory(qdiriterator)
add_subdirectory(qfile)
add_subdirectory(qfileinfo)
add_subdirectory(qiodevice)
-add_subdirectory(qtemporaryfile)
-add_subdirectory(qtextstream)
if(QT_FEATURE_process)
add_subdirectory(qprocess)
endif()
+add_subdirectory(qtemporaryfile)
+add_subdirectory(qtextstream)
+add_subdirectory(qurl)
diff --git a/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt b/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt
index e83c4e9acc..142c13aceb 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdir/10000/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from 10000.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qdir_10000 Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qdir_10000
SOURCES
- bench_qdir_10000.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qdir_10000.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:10000.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
index 3184df0d7b..a53742b536 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
+++ b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp
@@ -1,36 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// 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>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#else
# include <sys/stat.h>
# include <sys/types.h>
@@ -38,10 +15,12 @@
# include <unistd.h>
#endif
-class bench_QDir_10000 : public QObject{
- Q_OBJECT
+class tst_QDir_10000 : public QObject
+{
+ Q_OBJECT
public slots:
- void initTestCase() {
+ void initTestCase()
+ {
QDir testdir = QDir::tempPath();
const QString subfolder_name = QLatin1String("test_speed");
@@ -53,24 +32,16 @@ public slots:
file.open(QIODevice::WriteOnly);
}
}
- 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"));
+ void cleanupTestCase()
+ {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ QVERIFY(testdir.removeRecursively());
}
private slots:
- void baseline() {}
-
- void sizeSpeed() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ void sizeSpeed()
+ {
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QFileInfoList fileInfoList = testdir.entryInfoList(QDir::Files, QDir::Unsorted);
foreach (const QFileInfo &fileInfo, fileInfoList) {
fileInfo.isDir();
@@ -78,43 +49,47 @@ private slots:
}
}
}
- void sizeSpeedIterator() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ void sizeSpeedIterator()
+ {
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QDirIterator dit(testdir.path(), QDir::Files);
while (dit.hasNext()) {
- dit.next();
- dit.fileInfo().isDir();
- dit.fileInfo().size();
+ const auto fi = dit.nextFileInfo();
+ (void)fi.isDir();
+ (void)fi.size();
}
}
}
- void sizeSpeedWithoutFilter() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ void sizeSpeedWithoutFilter()
+ {
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QFileInfoList fileInfoList = testdir.entryInfoList(QDir::NoFilter, QDir::Unsorted);
foreach (const QFileInfo &fileInfo, fileInfoList) {
fileInfo.size();
}
}
}
- void sizeSpeedWithoutFilterIterator() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
+ void sizeSpeedWithoutFilterIterator()
+ {
QBENCHMARK {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
QDirIterator dit(testdir.path());
while (dit.hasNext()) {
- dit.next();
- dit.fileInfo().isDir();
- dit.fileInfo().size();
+ const auto fi = dit.nextFileInfo();
+ (void)fi.isDir();
+ (void)fi.size();
}
}
}
- void sizeSpeedWithoutFileInfoList() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Unsorted);
+ void sizeSpeedWithoutFileInfoList()
+ {
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);
@@ -123,18 +98,20 @@ private slots:
}
}
- void iDontWantAnyStat() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Unsorted);
- testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
+ void iDontWantAnyStat()
+ {
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);
}
}
}
- void iDontWantAnyStatIterator() {
+ void iDontWantAnyStatIterator()
+ {
QBENCHMARK {
QDirIterator dit(QDir::tempPath() + QLatin1String("/test_speed"));
while (dit.hasNext()) {
@@ -143,11 +120,12 @@ private slots:
}
}
- void sorted_byTime() {
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
- testdir.setSorting(QDir::Time);
- testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
+ void sorted_byTime()
+ {
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);
@@ -155,7 +133,17 @@ private slots:
}
}
- void sizeSpeedWithoutFilterLowLevel() {
+ 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"));
#ifdef Q_OS_WIN
const wchar_t *dirpath = (wchar_t*)testdir.absolutePath().utf16();
@@ -163,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;
@@ -188,11 +176,12 @@ private slots:
item = readdir(dir);
}
+ closedir(dir);
}
- closedir(dir);
#endif
}
};
-QTEST_MAIN(bench_QDir_10000)
-#include "bench_qdir_10000.moc"
+QTEST_MAIN(tst_QDir_10000)
+
+#include "tst_bench_qdir_10000.moc"
diff --git a/tests/benchmarks/corelib/io/qdir/CMakeLists.txt b/tests/benchmarks/corelib/io/qdir/CMakeLists.txt
index 10185014fa..00991de9a9 100644
--- a/tests/benchmarks/corelib/io/qdir/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdir/CMakeLists.txt
@@ -1,3 +1,4 @@
-# Generated from qdir.pro.
-
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(10000)
+add_subdirectory(tree)
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 c60bfcfdc3..f60c108480 100644
--- a/tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdir/tree/CMakeLists.txt
@@ -1,28 +1,25 @@
-# Generated from tree.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
-## bench_qdir_tree Binary:
+## tst_bench_qdir_tree Binary:
#####################################################################
-qt_internal_add_benchmark(bench_qdir_tree
+qt_internal_add_benchmark(tst_bench_qdir_tree
SOURCES
- bench_qdir_tree.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qdir_tree.cpp
+ LIBRARIES
Qt::Test
)
# Resources:
-set(bench_qdir_tree_resource_files
+set(qdir_tree_resource_files
"4.6.0-list.txt"
)
-qt_internal_add_resource(bench_qdir_tree "bench_qdir_tree"
+qt_internal_add_resource(tst_bench_qdir_tree "tst_bench_qdir_tree"
PREFIX
"/"
FILES
- ${bench_qdir_tree_resource_files}
+ ${qdir_tree_resource_files}
)
-
-
-#### Keys ignored in scope 1:.:.:tree.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp
index 0abf8769a6..4f122c876c 100644
--- a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp
+++ b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QTest>
@@ -35,14 +10,14 @@
#include "../../../../../shared/filesystem.h"
-class bench_QDir_tree
+class tst_QDir_tree
: public QObject
{
Q_OBJECT
public:
- bench_QDir_tree()
- : prefix("./test-tree/"),
+ tst_QDir_tree()
+ : prefix("test-tree/"),
musicprefix(QLatin1String("music")),
photoprefix(QLatin1String("photos")),
sourceprefix(QLatin1String("source")),
@@ -60,6 +35,7 @@ private:
qint64 musicsize;
qint64 photosize;
qint64 sourcesize;
+ FileSystem fs; // Uses QTemporaryDir to tidy away file tree created.
private slots:
void initTestCase()
@@ -71,7 +47,7 @@ private slots:
QStack<QByteArray> stack;
QByteArray line;
- Q_FOREVER {
+ while (true) {
char ch;
if (!list.getChar(&ch))
break;
@@ -89,12 +65,11 @@ private slots:
--pop;
}
- line = list.readLine();
- line.chop(1);
+ line = list.readLine().trimmed();
stack.push(line);
line = prefix;
- Q_FOREACH(const QByteArray &pathElement, stack)
+ for (const QByteArray &pathElement : std::as_const(stack))
line += pathElement;
if (line.endsWith('/'))
@@ -140,13 +115,11 @@ private slots:
QTest::addColumn<int>("filter");
QTest::addColumn<int>("entryCount");
- QTest::newRow("*.cpp") << QStringList("*.cpp")
- << int(QDir::Files)
- << 3813;
-
- QTest::newRow("executables") << QStringList("*")
+ QTest::newRow("*.cpp") << QStringList("*.cpp") << int(QDir::Files) << 3791;
+ QTest::newRow("executables")
+ << QStringList("*")
<< int(QDir::Executable | QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot)
- << 543;
+ << 536;
}
void fileSearch() const
@@ -158,8 +131,9 @@ private slots:
int count = 0;
QBENCHMARK {
// Recursive directory iteration
- QDirIterator iterator(prefix, nameFilters, QDir::Filter(filter),
- QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+ QDirIterator iterator(fs.absoluteFilePath(prefix),
+ nameFilters, QDir::Filter(filter),
+ QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
count = 0;
while (iterator.hasNext()) {
@@ -177,7 +151,8 @@ private slots:
{
int count = 0;
QBENCHMARK {
- QDirIterator iterator(prefix,
+ QDirIterator iterator(
+ fs.absoluteFilePath(prefix),
QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System,
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
@@ -187,10 +162,10 @@ private slots:
++count;
}
- QCOMPARE(count, 11963);
+ QCOMPARE(count, 11906);
}
- QCOMPARE(count, 11963);
+ QCOMPARE(count, 11906);
}
void thousandFiles_data() const
@@ -209,19 +184,18 @@ private slots:
QBENCHMARK {
qint64 totalsize = 0;
int count = 0;
- QDirIterator iter(dirName, QDir::Files, QDirIterator::Subdirectories);
+ QDirIterator iter(fs.absoluteFilePath(dirName),
+ QDir::Files, QDirIterator::Subdirectories);
while(iter.hasNext()) {
- iter.next();
count++;
- totalsize += iter.fileInfo().size();
+ totalsize += iter.nextFileInfo().size();
}
QCOMPARE(count, 1000);
QCOMPARE(totalsize, expectedSize);
}
}
-private:
- FileSystem fs;
};
-QTEST_MAIN(bench_QDir_tree)
-#include "bench_qdir_tree.moc"
+QTEST_MAIN(tst_QDir_tree)
+
+#include "tst_bench_qdir_tree.moc"
diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.qrc
index d57cb6c368..d57cb6c368 100644
--- a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc
+++ b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.qrc
diff --git a/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt b/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt
index 8ba331a113..6a4579d35d 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qdiriterator/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qdiriterator.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qdiriterator Binary:
@@ -6,9 +7,9 @@
qt_internal_add_benchmark(tst_bench_qdiriterator
SOURCES
- main.cpp
+ 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 10b1b90ce2..16b64cf362 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
/*!
\since 4.5
@@ -85,7 +60,7 @@
#include <qplatformdefs.h>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#else
# include <sys/stat.h>
# include <sys/types.h>
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
index 26bd2f59d9..479ce7b392 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// 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/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp
index 8c180f8757..66448bf838 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/tst_bench_qdiriterator.cpp
@@ -1,32 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QDirIterator>
+#include <QDirListing>
#include <QString>
#include <qplatformdefs.h>
@@ -48,23 +24,37 @@
#include <filesystem>
#endif
-class tst_qdiriterator : public QObject
+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();
void stdRecursiveDirectoryIterator_data() { data(); }
};
-void tst_qdiriterator::data()
+void tst_QDirIterator::data()
{
const char hereRelative[] = "tests/benchmarks/corelib/io/qdiriterator";
QByteArray dir(QT_TESTCASE_SOURCEDIR);
@@ -143,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());
}
@@ -155,7 +156,7 @@ static int posix_helper(const char *dirpath)
#endif
-void tst_qdiriterator::posix()
+void tst_QDirIterator::posix()
{
QFETCH(QByteArray, dirpath);
@@ -173,7 +174,7 @@ void tst_qdiriterator::posix()
qDebug() << count;
}
-void tst_qdiriterator::diriterator()
+void tst_QDirIterator::diriterator()
{
QFETCH(QByteArray, dirpath);
@@ -182,20 +183,40 @@ 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()) {
- dir.next();
+ const auto fi = dir.nextFileInfo();
+ if (forceStat)
+ fi.size();
//printf("%s\n", qPrintable(dir.fileName()));
0 && printf("%d %s\n",
- dir.fileInfo().isDir(),
- //qPrintable(dir.fileInfo().absoluteFilePath()),
+ fi.isDir(),
+ //qPrintable(fi.absoluteFilePath()),
//qPrintable(dir.path()),
- qPrintable(dir.filePath()));
+ qPrintable(fi.filePath()));
+ ++c;
+ }
+ count = c;
+ }
+ 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;
@@ -203,7 +224,7 @@ void tst_qdiriterator::diriterator()
qDebug() << count;
}
-void tst_qdiriterator::fsiterator()
+void tst_QDirIterator::fsiterator()
{
QFETCH(QByteArray, dirpath);
@@ -214,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()),
@@ -235,17 +254,23 @@ void tst_qdiriterator::fsiterator()
qDebug() << count;
}
-void tst_qdiriterator::stdRecursiveDirectoryIterator()
+void tst_QDirIterator::stdRecursiveDirectoryIterator()
{
#if QT_CONFIG(cxx17_filesystem)
QFETCH(QByteArray, dirpath);
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++;
}
@@ -257,6 +282,6 @@ void tst_qdiriterator::stdRecursiveDirectoryIterator()
#endif
}
-QTEST_MAIN(tst_qdiriterator)
+QTEST_MAIN(tst_QDirIterator)
-#include "main.moc"
+#include "tst_bench_qdiriterator.moc"
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 e7026c70f9..b805726f5f 100644
--- a/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
+++ b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QTemporaryFile>
@@ -38,7 +13,7 @@
#include <stdio.h>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#endif
#if defined(Q_OS_QNX) && defined(open)
@@ -263,7 +238,7 @@ void tst_qfile::readBigFile()
#ifdef QT_BUILD_INTERNAL
case QFSFileEngineBenchmark: {
QFSFileEngine fse(tempDir.filename);
- fse.open(QIODevice::ReadOnly|textMode|bufferedMode);
+ fse.open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt);
QBENCHMARK {
//qWarning() << fse.supportsExtension(QAbstractFileEngine::AtEndExtension);
while (fse.read(buffer, blockSize)) {}
@@ -349,7 +324,7 @@ void tst_qfile::seek()
#ifdef QT_BUILD_INTERNAL
case QFSFileEngineBenchmark: {
QFSFileEngine fse(tempDir.filename);
- fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt);
QBENCHMARK {
i=(i+1)%sp_size;
fse.seek(seekpos[i]);
@@ -426,7 +401,7 @@ void tst_qfile::open()
case QFSFileEngineBenchmark: {
QBENCHMARK {
QFSFileEngine fse(tempDir.filename);
- fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt);
fse.close();
}
}
@@ -533,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;
}
@@ -550,16 +525,16 @@ void tst_qfile::readSmallFiles()
QList<QFSFileEngine*> fileList;
for (const QString &file : files) {
QFSFileEngine *fse = new QFSFileEngine(tempDir.filePath(file));
- fse->open(QIODevice::ReadOnly|textMode|bufferedMode);
+ fse->open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt);
fileList.append(fse);
}
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;
}
@@ -572,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 1c088bf71a..84a667ca7d 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qfileinfo/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qfileinfo.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qfileinfo Binary:
@@ -6,11 +7,8 @@
qt_internal_add_benchmark(tst_bench_qfileinfo
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qfileinfo.cpp
+ LIBRARIES
Qt::CorePrivate
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qfileinfo.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/io/qfileinfo/main.cpp b/tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp
index 2cd06eef27..2c626dde70 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/main.cpp
+++ b/tests/benchmarks/corelib/io/qfileinfo/tst_bench_qfileinfo.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <qtest.h>
#include <QTest>
@@ -35,7 +10,7 @@
#include "private/qfsfileengine_p.h"
#include "../../../../shared/filesystem.h"
-class qfileinfo : public QObject
+class tst_QFileInfo : public QObject
{
Q_OBJECT
private slots:
@@ -45,34 +20,22 @@ private slots:
void symLinkTargetPerformanceLNK();
void junctionTargetPerformanceMountpoint();
#endif
- void initTestCase();
- void cleanupTestCase();
-public:
- qfileinfo() : QObject() {};
};
-void qfileinfo::initTestCase()
-{
-}
-
-void qfileinfo::cleanupTestCase()
-{
-}
-
-void qfileinfo::existsTemporary()
+void tst_QFileInfo::existsTemporary()
{
QString appPath = QCoreApplication::applicationFilePath();
QBENCHMARK { QFileInfo(appPath).exists(); }
}
-void qfileinfo::existsStatic()
+void tst_QFileInfo::existsStatic()
{
QString appPath = QCoreApplication::applicationFilePath();
QBENCHMARK { QFileInfo::exists(appPath); }
}
#if defined(Q_OS_WIN)
-void qfileinfo::symLinkTargetPerformanceLNK()
+void tst_QFileInfo::symLinkTargetPerformanceLNK()
{
QVERIFY(QFile::link("file","link.lnk"));
QFileInfo info("link.lnk");
@@ -86,7 +49,7 @@ void qfileinfo::symLinkTargetPerformanceLNK()
QVERIFY(QFile::remove("link.lnk"));
}
-void qfileinfo::junctionTargetPerformanceMountpoint()
+void tst_QFileInfo::junctionTargetPerformanceMountpoint()
{
wchar_t buffer[MAX_PATH];
QString rootPath = QDir::toNativeSeparators(QDir::rootPath());
@@ -109,6 +72,6 @@ void qfileinfo::junctionTargetPerformanceMountpoint()
}
#endif
-QTEST_MAIN(qfileinfo)
+QTEST_MAIN(tst_QFileInfo)
-#include "main.moc"
+#include "tst_bench_qfileinfo.moc"
diff --git a/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt b/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt
index 3af6d4f214..133a9a1ac3 100644
--- a/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qiodevice/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qiodevice.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qiodevice Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qiodevice
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qiodevice.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qiodevice.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/io/qiodevice/main.cpp b/tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp
index de4660a253..cae90631ee 100644
--- a/tests/benchmarks/corelib/io/qiodevice/main.cpp
+++ b/tests/benchmarks/corelib/io/qiodevice/tst_bench_qiodevice.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
#include <QFile>
@@ -32,8 +7,7 @@
#include <qtest.h>
-
-class tst_qiodevice : public QObject
+class tst_QIODevice : public QObject
{
Q_OBJECT
private slots:
@@ -48,7 +22,7 @@ private:
};
-void tst_qiodevice::read_data()
+void tst_QIODevice::read_data()
{
QTest::addColumn<qint64>("size");
QTest::newRow("10k") << qint64(10 * 1024);
@@ -59,7 +33,7 @@ void tst_qiodevice::read_data()
QTest::newRow("1000000k") << qint64(1000000 * 1024);
}
-void tst_qiodevice::read_old()
+void tst_QIODevice::read_old()
{
QFETCH(qint64, size);
@@ -88,7 +62,7 @@ void tst_qiodevice::read_old()
}
}
-void tst_qiodevice::peekAndRead()
+void tst_QIODevice::peekAndRead()
{
QFETCH(qint64, size);
@@ -119,6 +93,6 @@ void tst_qiodevice::peekAndRead()
}
}
-QTEST_MAIN(tst_qiodevice)
+QTEST_MAIN(tst_QIODevice)
-#include "main.moc"
+#include "tst_bench_qiodevice.moc"
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 ca7011a661..c8837d3d65 100644
--- a/tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qprocess/test/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from test.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qprocess Binary:
@@ -7,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 896435b27b..cd486bd9cc 100644
--- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
#####################################################################
## testProcessLoopback Binary:
#####################################################################
-add_executable(testProcessLoopback main.cpp)
+add_executable(testProcessLoopback loopback.cpp)
diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp
new file mode 100644
index 0000000000..1f47f6b0f1
--- /dev/null
+++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/loopback.cpp
@@ -0,0 +1,19 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+
+#include <stdio.h>
+
+int main()
+{
+ char buffer[1024];
+ for (;;) {
+ size_t num = fread(buffer, 1, sizeof(buffer), stdin);
+ if (num <= 0)
+ break;
+ fwrite(buffer, num, 1, stdout);
+ fflush(stdout);
+ }
+
+ return 0;
+}
diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/main.cpp b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/main.cpp
deleted file mode 100644
index 1773ba7496..0000000000
--- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/main.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <stdio.h>
-
-int main()
-{
- char buffer[1024];
- for (;;) {
- size_t num = fread(buffer, 1, sizeof(buffer), stdin);
- if (num <= 0)
- break;
- fwrite(buffer, num, 1, stdout);
- fflush(stdout);
- }
-
- return 0;
-}
diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
index 0bc0332c6f..9cf87a6653 100644
--- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
+++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QSignalSpy>
@@ -68,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 a12bfd1260..a2a33a0dce 100644
--- a/tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qtemporaryfile.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qtemporaryfile Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qtemporaryfile
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qtemporaryfile.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qtemporaryfile.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/main.cpp b/tests/benchmarks/corelib/io/qtemporaryfile/main.cpp
deleted file mode 100644
index c50032d174..0000000000
--- a/tests/benchmarks/corelib/io/qtemporaryfile/main.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QDebug>
-#include <QIODevice>
-#include <QFile>
-#include <QString>
-#include <QTemporaryFile>
-#include <qtest.h>
-
-
-class tst_qtemporaryfile : public QObject
-{
- Q_OBJECT
-private slots:
- void openclose_data();
- void openclose();
- void readwrite_data() { openclose_data(); }
- void readwrite();
-
-private:
-};
-
-void tst_qtemporaryfile::openclose_data()
-{
- QTest::addColumn<qint64>("amount");
- QTest::newRow("100") << qint64(100);
- QTest::newRow("1000") << qint64(1000);
- QTest::newRow("10000") << qint64(10000);
-}
-
-void tst_qtemporaryfile::openclose()
-{
- QFETCH(qint64, amount);
-
- QBENCHMARK {
- for (qint64 i = 0; i < amount; ++i) {
- QTemporaryFile file;
- file.open();
- file.close();
- }
- }
-}
-
-void tst_qtemporaryfile::readwrite()
-{
- QFETCH(qint64, amount);
-
- const int dataSize = 4096;
- QByteArray data;
- data.fill('a', dataSize);
- QBENCHMARK {
- for (qint64 i = 0; i < amount; ++i) {
- QTemporaryFile file;
- file.open();
- file.write(data);
- file.seek(0);
- file.read(dataSize);
- file.close();
- }
- }
-}
-
-QTEST_MAIN(tst_qtemporaryfile)
-
-#include "main.moc"
diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp b/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp
new file mode 100644
index 0000000000..c72b525827
--- /dev/null
+++ b/tests/benchmarks/corelib/io/qtemporaryfile/tst_bench_qtemporaryfile.cpp
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#include <QDebug>
+#include <QIODevice>
+#include <QFile>
+#include <QString>
+#include <QTemporaryFile>
+#include <qtest.h>
+
+class tst_QTemporaryFile : public QObject
+{
+ Q_OBJECT
+private slots:
+ void openclose_data();
+ void openclose();
+ void readwrite_data() { openclose_data(); }
+ void readwrite();
+
+private:
+};
+
+void tst_QTemporaryFile::openclose_data()
+{
+ QTest::addColumn<qint64>("amount");
+ QTest::newRow("100") << qint64(100);
+ QTest::newRow("1000") << qint64(1000);
+ QTest::newRow("10000") << qint64(10000);
+}
+
+void tst_QTemporaryFile::openclose()
+{
+ QFETCH(qint64, amount);
+
+ QBENCHMARK {
+ for (qint64 i = 0; i < amount; ++i) {
+ QTemporaryFile file;
+ file.open();
+ file.close();
+ }
+ }
+}
+
+void tst_QTemporaryFile::readwrite()
+{
+ QFETCH(qint64, amount);
+
+ const int dataSize = 4096;
+ QByteArray data;
+ data.fill('a', dataSize);
+ QBENCHMARK {
+ for (qint64 i = 0; i < amount; ++i) {
+ QTemporaryFile file;
+ file.open();
+ file.write(data);
+ file.seek(0);
+ file.read(dataSize);
+ file.close();
+ }
+ }
+}
+
+QTEST_MAIN(tst_QTemporaryFile)
+
+#include "tst_bench_qtemporaryfile.moc"
diff --git a/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt b/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt
index 0393b91119..5e39b2fd90 100644
--- a/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qtextstream/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qtextstream.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_bench_qtextstream Binary:
@@ -6,10 +7,7 @@
qt_internal_add_benchmark(tst_bench_qtextstream
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qtextstream.cpp
+ LIBRARIES
Qt::Test
)
-
-#### Keys ignored in scope 1:.:.:qtextstream.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/benchmarks/corelib/io/qtextstream/main.cpp b/tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp
index 03dc3d1694..74552b85cf 100644
--- a/tests/benchmarks/corelib/io/qtextstream/main.cpp
+++ b/tests/benchmarks/corelib/io/qtextstream/tst_bench_qtextstream.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 David Faure <david.faure@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 David Faure <david.faure@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
@@ -32,7 +7,7 @@
#include <QBuffer>
#include <qtest.h>
-class tst_qtextstream : public QObject
+class tst_QTextStream : public QObject
{
Q_OBJECT
private slots:
@@ -48,7 +23,7 @@ Q_DECLARE_METATYPE(Output);
enum Input { CharStarInput, QStringInput, CharInput, QCharInput };
Q_DECLARE_METATYPE(Input);
-void tst_qtextstream::writeSingleChar_data()
+void tst_QTextStream::writeSingleChar_data()
{
QTest::addColumn<Output>("output");
QTest::addColumn<Input>("input");
@@ -63,7 +38,7 @@ void tst_qtextstream::writeSingleChar_data()
QTest::newRow("device_qchar") << DeviceOutput << QCharInput;
}
-void tst_qtextstream::writeSingleChar()
+void tst_QTextStream::writeSingleChar()
{
QFETCH(Output, output);
QFETCH(Input, input);
@@ -115,6 +90,6 @@ void tst_qtextstream::writeSingleChar()
QCOMPARE(result.left(10), QString("hhhhhhhhhh"));
}
-QTEST_MAIN(tst_qtextstream)
+QTEST_MAIN(tst_QTextStream)
-#include "main.moc"
+#include "tst_bench_qtextstream.moc"
diff --git a/tests/benchmarks/corelib/io/qurl/CMakeLists.txt b/tests/benchmarks/corelib/io/qurl/CMakeLists.txt
index d38c8b18c0..fc8d48450d 100644
--- a/tests/benchmarks/corelib/io/qurl/CMakeLists.txt
+++ b/tests/benchmarks/corelib/io/qurl/CMakeLists.txt
@@ -1,23 +1,21 @@
-# Generated from qurl.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qurl Binary:
#####################################################################
-qt_internal_add_benchmark(tst_qurl
+qt_internal_add_benchmark(tst_bench_qurl
SOURCES
- main.cpp
- PUBLIC_LIBRARIES
+ tst_bench_qurl.cpp
+ LIBRARIES
Qt::Test
)
-#### Keys ignored in scope 1:.:.:qurl.pro:<TRUE>:
-# TEMPLATE = "app"
-
## Scopes:
#####################################################################
-qt_internal_extend_target(tst_qurl CONDITION WIN32
+qt_internal_extend_target(tst_bench_qurl CONDITION WIN32
DEFINES
_CRT_SECURE_NO_WARNINGS
)
diff --git a/tests/benchmarks/corelib/io/qurl/main.cpp b/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp
index 5ad3c3bd47..87c4f51816 100644
--- a/tests/benchmarks/corelib/io/qurl/main.cpp
+++ b/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp
@@ -1,35 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qurl.h>
#include <qtest.h>
-class tst_qurl: public QObject
+class tst_QUrl : public QObject
{
Q_OBJECT
@@ -53,28 +28,28 @@ private:
void generateFirstRunData();
};
-void tst_qurl::emptyUrl()
+void tst_QUrl::emptyUrl()
{
QBENCHMARK {
QUrl url;
}
}
-void tst_qurl::relativeUrl()
+void tst_QUrl::relativeUrl()
{
QBENCHMARK {
QUrl url("pics/avatar.png");
}
}
-void tst_qurl::absoluteUrl()
+void tst_QUrl::absoluteUrl()
{
QBENCHMARK {
QUrl url("/tmp/avatar.png");
}
}
-void tst_qurl::generateFirstRunData()
+void tst_QUrl::generateFirstRunData()
{
QTest::addColumn<bool>("firstRun");
@@ -82,12 +57,12 @@ void tst_qurl::generateFirstRunData()
QTest::newRow("subsequent runs") << false;
}
-void tst_qurl::isRelative_data()
+void tst_QUrl::isRelative_data()
{
generateFirstRunData();
}
-void tst_qurl::isRelative()
+void tst_QUrl::isRelative()
{
QFETCH(bool, firstRun);
if (firstRun) {
@@ -103,12 +78,12 @@ void tst_qurl::isRelative()
}
}
-void tst_qurl::toLocalFile_data()
+void tst_QUrl::toLocalFile_data()
{
generateFirstRunData();
}
-void tst_qurl::toLocalFile()
+void tst_QUrl::toLocalFile()
{
QFETCH(bool, firstRun);
if (firstRun) {
@@ -124,12 +99,12 @@ void tst_qurl::toLocalFile()
}
}
-void tst_qurl::toString_data()
+void tst_QUrl::toString_data()
{
generateFirstRunData();
}
-void tst_qurl::toString()
+void tst_QUrl::toString()
{
QFETCH(bool, firstRun);
if(firstRun) {
@@ -145,35 +120,37 @@ void tst_qurl::toString()
}
}
-void tst_qurl::resolved_data()
+void tst_QUrl::resolved_data()
{
generateFirstRunData();
}
-void tst_qurl::resolved()
+void tst_QUrl::resolved()
{
QFETCH(bool, firstRun);
- if(firstRun) {
+ QUrl expect("/home/user/pics/avatar.png"), actual;
+ if (firstRun) {
QBENCHMARK {
QUrl baseUrl("/home/user/");
QUrl url("pics/avatar.png");
- baseUrl.resolved(url);
+ actual = baseUrl.resolved(url);
}
} else {
QUrl baseUrl("/home/user/");
QUrl url("pics/avatar.png");
QBENCHMARK {
- baseUrl.resolved(url);
+ actual = baseUrl.resolved(url);
}
}
+ QCOMPARE(actual, expect);
}
-void tst_qurl::equality_data()
+void tst_QUrl::equality_data()
{
generateFirstRunData();
}
-void tst_qurl::equality()
+void tst_QUrl::equality()
{
QFETCH(bool, firstRun);
if(firstRun) {
@@ -186,12 +163,12 @@ void tst_qurl::equality()
QUrl url("pics/avatar.png");
QUrl url2("pics/avatar2.png");
QBENCHMARK {
- url == url2;
+ [[maybe_unused]] auto r = url == url2;
}
}
}
-void tst_qurl::qmlPropertyWriteUseCase()
+void tst_QUrl::qmlPropertyWriteUseCase()
{
QUrl base("file:///home/user/qt/examples/declarative/samegame/SamegameCore/");
QString str("pics/redStar.png");
@@ -203,6 +180,6 @@ void tst_qurl::qmlPropertyWriteUseCase()
}
}
-QTEST_MAIN(tst_qurl)
+QTEST_MAIN(tst_QUrl)
-#include "main.moc"
+#include "tst_bench_qurl.moc"