diff options
Diffstat (limited to 'tests/benchmarks/corelib/io')
15 files changed, 81 insertions, 29 deletions
diff --git a/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/tst_bench_qdir_10000.cpp index 80dbc0f141..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> diff --git a/tests/benchmarks/corelib/io/qdir/CMakeLists.txt b/tests/benchmarks/corelib/io/qdir/CMakeLists.txt index f1800fc0cd..00991de9a9 100644 --- a/tests/benchmarks/corelib/io/qdir/CMakeLists.txt +++ b/tests/benchmarks/corelib/io/qdir/CMakeLists.txt @@ -1,2 +1,4 @@ +# 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/tst_bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/tst_bench_qdir_tree.cpp index 773f17a35a..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> 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/tst_bench_qfile.cpp b/tests/benchmarks/corelib/io/qfile/tst_bench_qfile.cpp index b7e32be259..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> 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/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/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 424ff88048..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> 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/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/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> |