summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash in tst_qquicktext::implicitSizeEskil Abrahamsen Blomfeldt2022-05-201-37/+0
| | | | | | | | | | | | | This reverts commit 1e938c348b936328fafbcaae4c0c7d91003143e5 and bb2f4d08d9d138e4f70d6d6db46e24e34500becc. bb2f4d08d9d causes the crash, but 1e938c348b93 amends it, so this reverts both. When the cause of the crash has been determined and mitigated, the patches can be recreated. Fixes: QTBUG-103719 Change-Id: Ifc36b3771a96f6c85387a5306a0402d4c508d006 Reviewed-by: David Faure <david.faure@kdab.com>
* QTextDocument: add setLayoutEnabled()David Faure2022-05-191-0/+18
| | | | | | | | | | | This allows to set up everything first - without paying for layouting at every step - and only then trigger layouting. Same performance behavior as setTextWidth(0), but this is a more explicit/readable API. Change-Id: I044dbd8b1301b1c97a92f9a29ccde2baf27a7665 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextDocument/QGraphicsTextItem: skip layout in setTextWidth(0)David Faure2022-05-171-0/+19
| | | | | | | | | | | | | | | | | | In a QGraphicsTextItem without a width yet, there's no need to do any layouting. The use case is obviously items with an app-defined size, not the default where text items adapt to their contents. Results: 0.065 msecs to create a QGraphicsTextItem with some text (layouted) 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width QTextEdit was abusing the width 0 to mean "no wrap, width comes from contents", but since the value -1 means that already in QTextDocument, QTextEdit now uses a width of -1 for that meaning. Change-Id: I67ad59c305e5dd34830886e4e6c56dde03c93668 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-16201-5432/+407
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QWidgetTextControl: port to new-style connects (faster)David Faure2022-05-101-0/+11
| | | | | | | | | | | | | | | This speeds up creating a QGraphicsTextItem by 14% in an optimized build Before: 0.070 msecs per iteration After: 0.060 msecs per iteration Those connects were showing up when profiling, because of the string parsing that is necessary when using SIGNAL/SLOT macros. The stacktrace was connect() => decodeMethodSignature() => argumentTypesFromString() => QArgumentType constructor => qMetaTypeInternal(const char*). Pick-to: 6.3 6.2 5.15 Change-Id: I3cf5655c5450f121005140bdb587fafa083cce6a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* benchmarks: fix deprecation warningsMarc Mutz2022-04-062-5/+5
| | | | | | | | | - count() -> size() - QCryptographicHash::addData(ptr, ch) -> ({ptr, ch}) (QByteArrayView overload) Pick-to: 6.3 Change-Id: I15dddfa5c4385dd2a0fa0c3ae06c303c7151e2dc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* More startOfDay() fixes, in tst_bench_QDateTimeEdward Welbourne2022-03-311-4/+5
| | | | | | | | | | | Update a QDateTime benchmark to use QDate::startOfDay() when setting up its lists of date-times in helper functions, and to use noon as the moment in the day in a creation test. Also move creation of a QTime outside the loop: we're testing speed of creation of QDateTime here, not QTime (and were already using the most trivial QTime constructor). Change-Id: I26bf3369aae84a802ab03791f7341e107fede87c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix lancebench after lancelot restructuringAllan Sandfeld Jensen2022-03-171-1/+1
| | | | | | Pick-to: 6.3 6.2 Change-Id: I5e17230761ca5482b3376787afab29d15de58dac Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Benchmarks: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | Change-Id: I1d0dbfca130f43d76de2d6ac585a0f242d490b5a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+2
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QByteArray benchmark: fix clang -Wmove-resultMarc Mutz2022-01-241-1/+1
| | | | | | | | | | | | | | | | | Take the argument by value instead of rvalue ref. In C++17, this is as efficient, and enables the return big; to use the QByteArray move constructor, avoiding the need for a manual std::move(), which always looks suspicious on a return statement, because more often than not, it's a pessimization that breaks NRVO. This code doesn't seem to exist in Qt 6.2, so only Pick-to: 6.3 Change-Id: I8bf678102f5df1870cfc61090d12f327478d74d1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* benchmarks: fix some (future) -Wunused-result warningsMarc Mutz2022-01-243-28/+28
| | | | | | | | | | | | | | | | | | | | Clang 10 warns about unused results of relational operators, which is where this is coming from. Fix by adding the usual prefix [[maybe_unused]] auto r = ~~~; to silence the warning. Do this elsewhere, too, since [[nodiscard]] is slowly being rolled out across all our APIs. This is not a complete sweep, though. Not picking to 5.15, because this pattern doesn't work there and I don't want to introduce a new one. Pick-to: 6.3 6.2 Change-Id: I40dd8ad07496b686979dce533e044cbb486e30f3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_bench_qlocalsocket: fix Clang 10 warnings about unneeded captureMarc Mutz2022-01-241-2/+1
| | | | | | | | | | | | | | | | The timeToTest constant doesn't need to be captured, claims Clang. Since I don't recall seeing this warning on GCC, be pragmatic and fix by letting the compiler choose what to capture: [&]. timeToTest is const, so it doesn't matter whether we capture by reference or value, the lambda cannot change it either way. This code doesn't seem to exist in 5.15, so merely Pick-to: 6.3 6.2 Change-Id: I48d42ab13ed22ac5eb512dc61235b72a19636ea3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTransform benchmark: measure what was promisedMarc Mutz2022-01-241-1/+1
| | | | | | | | | | | | The function name suggests that the *= operator is to be benchmarked, not simple multiplication. Use the correct operator. Pick-to: 6.3 6.2 5.15 Change-Id: I6718e8aea640a153083858b39963199e7bab26e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use QPromise when creating continuations to avoid memory leaksSona Kurazyan2022-01-211-0/+1
| | | | | | | | | | | | | | | | | Continuations were using QFutureInterface to create and return the associated future to the user. Attaching a continuation to the returned future could cause memory leaks (described in an earlier commit). Use a QPromise when saving the continuation, to make sure that the attached continuation is cleaned in the destructor of the associated QPromise, so that it doesn't keep any ref-counted copies to the shared data, thus preventing it from being deleted. Task-number: QTBUG-99534 Pick-to: 6.3 6.2 Change-Id: I52d5501292095d41d1e060b7dd140c8e5d01335c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Baseline: Move the paintcommands code into the shared directoryVolker Hilsheimer2022-01-201-2/+2
| | | | | | | | | It's used by the lancebench and the lance tool, and it will probably be useful for writing some high-dpi related unit and baseline test cases, so move it to the shared folder. Change-Id: I969bab51c9504be13b4c192b4f29f69cd9102868 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-172-94/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix the benchmark for QList::removeAll()Sona Kurazyan2021-12-091-92/+25
| | | | | | | | | | | | | | | | | The benchmark was making assumptions about number of constructor/assignment operator calls, which are not valid in Qt 6, after the implementation of QList has changed. Considering that we already check number of constructions, copy constructions, etc., in tst_qlist.cpp, remove the checks from the benchmark. As a driveby, fix the following warning: "warning: parameter 'i' shadows member inherited from type 'MyBase'" Pick-to: 6.2 Fixes: QTBUG-95096 Change-Id: Ida68fa5803641c8fa84f8309c0093986ed4c0a2b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Optimize QMimeDatabase::mimeTypeForFile(f, MatchDefault)Igor Kushnir2021-12-067-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Open the file only if matching on content is needed. Use QFileInfo::filePath() instead of QFileInfo::absoluteFilePath() in QMimeDatabase::mimeTypeForFile(). filePath() does much less work, and so is faster. Thiago Macieira helpfully explained in a review comment why the absolute path is not useful for correctness here: "Nothing needs absolute paths within the same application that would resolve the relative path to absolute. You only need an absolute path if you're communicating with another application that may be in a different directory." QMimeDatabase::mimeTypeForFile() checks fileInfo.isDir(), so the fileName.endsWith(QLatin1Char('/')) check in QMimeDatabasePrivate::mimeTypeForFileNameAndData() was redundant when called from this function. The other two callers of that function now check this condition before opening IO devices. This improves performance of the two QMimeDatabase::mimeTypeForFileNameAndData() overloads in the corner case. Refactor and optimize QMimeDatabasePrivate::findByFileName() and its usages. Previously each caller constructed a QFileInfo object and passed QFileInfo::fileName() into this function. Now the callers simply pass an absolute or relative path to a file into this function, which then uses QFileSystemEntry::fileName() to exclude the path. Constructing QFileInfo is relatively expensive, so this change slightly improves performance. Optimize QMimeDatabasePrivate::loadProviders() by calling static QFileInfo::exists() instead of constructing a QFileInfo object and calling the non-static QFileInfo::exists() overload. Note that the QFileInfo object was always created, even if QFileInfo::exists() under an `if` and an `#if` was never called. The following table contains the average results of the added benchmark tst_QMimeDatabase::benchMimeTypeForFile() on my GNU/Linux system before and at this commit. The numbers denote milliseconds per iteration. data row tag before at MatchDefault: archive 0.029 0.016 OpenDocument Text 0.029 0.015 existent archive with extension 0.039 0.025 existent C with extension 0.033 0.020 existent text file with extension 0.033 0.020 existent C w/o extension 0.076 0.074 existent patch w/o extension 0.11 0.105 existent archive w/o extension 0.069 0.066 MatchExtension: archive 0.012 0.0115 OpenDocument Text 0.0115 0.011 existent archive with extension 0.017 0.016 existent C with extension 0.011 0.011 existent text file with extension 0.011 0.011 existent C w/o extension 0.016 0.0155 existent patch w/o extension 0.013 0.012 existent archive w/o extension 0.013 0.012 MatchContent: archive 0.019 0.012 OpenDocument Text 0.019 0.012 existent archive with extension 0.053 0.051 existent C with extension 0.056 0.0545 existent text file with extension 0.058 0.056 existent C w/o extension 0.0605 0.059 existent patch w/o extension 0.10 0.099 existent archive w/o extension 0.057 0.054 Change-Id: Idb541656e073a2c4822ace3f4da412f29f2351f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Remove chip.debug compiled binary leftover from debuggingDmitry Shachnev2021-12-061-0/+0
| | | | | | Pick-to: 6.2 Change-Id: I9d1ca06ffb5f9b8fc6e6042c399311dcec059521 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractFileEngine: Add permission argument to open()Ievgenii Meshcheriakov2021-12-041-4/+4
| | | | | | | | | The new argument allows atomic creation of files with non-default permissions. Task-number: QTBUG-79750 Change-Id: I4c49455b41f924ba87148302c8d0f77f5de0832b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QWaitCondition: also benchmark std::condition_variable{,_any}Marc Mutz2021-11-261-13/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results on my machine (only forever results): ********* Start testing of tst_QWaitCondition ********* Config: Using QtTest library 6.3.0, Qt 6.3.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.2.1 20211115), ubuntu 20.04 PASS : tst_QWaitCondition::oscillate_QWaitCondition_QMutex(forever) RESULT : tst_QWaitCondition::oscillate_QWaitCondition_QMutex():"forever": 637 msecs per iteration (total: 637, iterations: 1) PASS : tst_QWaitCondition::oscillate_QWaitCondition_QReadWriteLock(forever) RESULT : tst_QWaitCondition::oscillate_QWaitCondition_QReadWriteLock():"forever": 909 msecs per iteration (total: 909, iterations: 1) PASS : tst_QWaitCondition::oscillate_std_condition_variable_std_mutex(forever) RESULT : tst_QWaitCondition::oscillate_std_condition_variable_std_mutex():"forever": 331 msecs per iteration (total: 331, iterations: 1) PASS : tst_QWaitCondition::oscillate_std_condition_variable_any_QMutex(forever) RESULT : tst_QWaitCondition::oscillate_std_condition_variable_any_QMutex():"forever": 627 msecs per iteration (total: 627, iterations: 1) PASS : tst_QWaitCondition::oscillate_std_condition_variable_any_QReadWriteLock(forever) RESULT : tst_QWaitCondition::oscillate_std_condition_variable_any_QReadWriteLock():"forever": 913 msecs per iteration (total: 913, iterations: 1) ~331 vs. ~630ms. A pretty significant win (2x). Mårten noticed that on Windows, condition_variable::wait_for(x, 0ms) will not unlock the mutex, which, however, the program requires, so use a 1ns timeout instead. Drive-by fixes: - add override to run() reimplementations - fix type of timeout member variable (was int, should be unsigned long) - fix naming of test functions to distinguish better between QMutex and std::mutex Change-Id: Ib92310f15fbd58258b2043504642be5f0b860f39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QtBase: replace windows.h with qt_windows.hYuhang Zhao2021-11-234-4/+4
| | | | | | | | | | We have some special handling in qt_windows.h, use it instead of the original windows.h Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Rename and restructure the baseline (lancelot) testing codeEirik Aavitsland2021-11-162-5/+7
| | | | | | | | | | | | | | | | | | | | In preparation for addition of new baseline tests, establish a new test category, "baseline". This is similar to the category "benchmarks" in that it contains tests that use the QTest framework, but conceptually are not unit tests, in contrast to those under auto/. Move the existing QPainter baseline test, tst_lancelot, into this new category, and rename it accordingly. Baseline tests use the QBaselineTest extension to QTest. Move that extension too into the tests/baseline directory, allowing the clean out of the baselineserver directory. Pick-to: 6.2 Change-Id: I1b527f5867c953b1d22be73798fcf7d1494712ea Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QReadWriteLocker: also benchmark recursive modeMarc Mutz2021-11-151-0/+66
| | | | | Change-Id: Ic2e357f4702d05220cf6c96717672dcabacd78d6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Bump WINVER, _WIN32_WINNT and _WIN32_IE to _WIN32_WINNT_WIN10 (0x0A00)Yuhang Zhao2021-11-101-1/+3
| | | | | | | | | | | And bump NTDDI_VERSION to 0x0A00000B (NTDDI_WIN10_CO) at the same time, to unblock the developers from accessing the latest Windows APIs. Pick-to: 6.2 Change-Id: Ifbc28c8f8b073866871685c020301f5f20dc9591 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove checks for C++ standard versions C++17 and belowIevgenii Meshcheriakov2021-10-011-2/+0
| | | | | | | | | | | Qt requires a compiler that support C++17 thus __cplusplus is always 201703L or higher. This patch removes checks for __cplusplus value that always succeed. Change-Id: I4b830683ecefab8f913d8b09604086d53209d2e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Deprecate constructing QString from a pointerChen Wei2021-09-071-1/+1
| | | | | Change-Id: Ib37775567c12f23b220825c76a32b6c17ca5264b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add note to QList benchmark about known bugEdward Welbourne2021-08-301-0/+1
| | | | | | | Task-number: QTBUG-95096 Change-Id: I08f789f2e6ed70507da18e629140404f09bfae12 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Standardise layout and naming in corelib benchmarksEdward Welbourne2021-08-3095-524/+359
| | | | | | | | | | | | | | | Make file names match CMake's test names (and those follow dir-name) and class names follow tst_ClassName pattern when testing ClassName. Purge comments about the qmake configs the CMakeLists.txt are generated from. Purge empty constructors and init/cleanup methods of classes. Fix petty coding style violations. Add qdir/tree/, qurl, qbench and qset benchmarks to their parent directories' lists of subdirs. Fix unused return error from qurl benchmark. Change-Id: Ifc15a3a46e71cf82ad0637753517e0df34049763 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* New QByteArray::toU?LongLong() benchmarkEdward Welbourne2021-08-271-1/+90
| | | | | Change-Id: Ic0581dd5625f9b2750646c73dc80d89741d97a1d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix the (currently unbuilt) qdir/tree/ benchmarkEdward Welbourne2021-08-231-20/+19
| | | | | | | | | | | | | | It tried to find its test-data-directory locally, instead of asking FileSystem where it was keeping its files, relative to a temporary directory. Its expected counts didn't match the arcane results of its data file; since this is a benchmark, not a regression test, I'm assuming that's just because it was never right or the rules for QDirIterator's filtering have changed. Tidied up somewhat in the process. Change-Id: Ib2dcd314b11cb0f1a6fc425633afd0e9c39bd036 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Add benchmark for QByteArray::toPercentEncoding()Edward Welbourne2021-08-191-0/+31
| | | | | Change-Id: If822bb3b9c6623137f27b6624598530432246ed2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add benchmark for QMetaEnumMarc Mutz2021-08-163-0/+88
| | | | | Change-Id: If57f00b14713f2083260a00fd833da62d6f1cd57 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix some compiler warnings from deprecated QFont constructorVolker Hilsheimer2021-08-111-1/+1
| | | | | | | | QFont should be constructed with a list of font families. Pick-to: 6.2 Change-Id: I61141b25d3f6e25f4fea141acbfa8e164d7af58f Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* testlib: Deprecate QWARN() in favor of qWarning()Tor Arne Vestbø2021-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The QtTest best practices documentations recommends using output mechanisms such as qDebug() and qWarning() for diagnostic messages, and this is also what most of our own tests do. The QWARN() macro and corresponding internal QTest::qWarn() function was added when QtTest was first implemented, but was likely meant as an internal implementation detail, like its cousin QTestLog::info(), which does not have any corresponding macro. This theory is backed by our own QtTest self-test (tst_silent) describing the output from QWARN() as "an internal testlib warning". The only difference between QWARN() and qWarning(), besides the much richer feature set of the latter, is that qWarning() will not pass on file and line number information in release mode, but QWARN() will. This is an acceptable loss of functionality, considering that the user can override this behavior by defining QT_MESSAGELOGCONTEXT. [ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning() Pick-to: 6.2 Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString benchmark: don't use %lsMårten Nordheim2021-07-291-1/+1
| | | | | | | | The vsnprintf we use in QTest doesn't not have a portable %ls: It accepts wchar_t, so it's UTF-32 on Linux and UTF-16 on Windows Change-Id: I9ebda1e92b6e8e4dbbb79c6f2e35a833c587a089 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: fix some -WvolatileMarc Mutz2021-07-282-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 deprecated compound volatile statements such as pre- and post-increments, to stress that they're not atomic. So instead of volatile i; ~~~~; ++i; you're now supposed to write volatile i; ~~~~; int j = i; // volatile load ++j; i = j; // volatile store which matches more closely what hardware does. Instead of fixing every use of volatile pre- or post-increment in this fashion individually, and realising that probably a few more Qt modules will have the same kind of code patterns in them, write QtPrivate functions to do the job centrally. Change-Id: I838097bd484ef2118c071726963f103c080d2ba5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QDirIterator: add nextFileInfo()Marc Mutz2021-07-283-12/+11
| | | | | | | | | | | | | | | | | | | | | | | Before this change, next() was the only way to advance the iterator, whether the caller was ultimately interested in just the filePath() (good) or not (bad luck, had to call .fileInfo()). Add a new function, nextFileInfo(), with returns fileInfo() instead. Incidentally, the returned object has already been constructed as part of advance()ing the iterator, so the new function is faster than next() even if the result is ignored, because we're not calculating a QString result the caller may not be interested in. Use the new function around the code. Fix a couple of cases of next(); fileInfo().filePath() (just use next()'s return value) as a drive-by. [ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like next(), but returns fileInfo() instead of filePath(). Change-Id: I601220575961169b44139fc55b9eae6c3197afb4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix various -Wdeprecated-enum-float-conversions around the codeMarc Mutz2021-07-271-2/+4
| | | | | | | | | | | In two cases, it was as easy as replacing an unnamed enum's values with constexpr variables. In the case of QSimplex, I opted for qToUnderlying(), as the enum made sense on its own. Change-Id: Ifcf5be14bd2f35e50adabdbd7ecdb2e83f6bf5b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add a benchmark for QSharedPointerMarc Mutz2021-07-273-0/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initial results with GCC: Even though GCC's assembly looks rather bad because of the implicit fall-back from atomics to non-atomics for single-threaded applications, libstdc++'s shared_ptr still performs twice as fast as QSharedPointer, proving that the branch predictor eats libstdc++'s is-multi-threaded-check for breakfast and the two atomic operations of a QSharedPointer copy vs. one for std::shared_ptr dominate the run-time. ********* Start testing of tst_QSharedPointer ********* Config: Using QtTest library 6.2.0, Qt 6.2.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.1.1 20210712), ubuntu 20.04 PASS : tst_QSharedPointer::initTestCase() PASS : tst_QSharedPointer::refAndDeref_null_QSP_int() RESULT : tst_QSharedPointer::refAndDeref_null_QSP_int(): 0.0000024 msecs per iteration (total: 81, iterations: 33554432) PASS : tst_QSharedPointer::refAndDeref_null_SSP_int() RESULT : tst_QSharedPointer::refAndDeref_null_SSP_int(): 0.0000024 msecs per iteration (total: 81, iterations: 33554432) PASS : tst_QSharedPointer::refAndDeref_null_BSP_int() RESULT : tst_QSharedPointer::refAndDeref_null_BSP_int(): 0.0000025 msecs per iteration (total: 87, iterations: 33554432) PASS : tst_QSharedPointer::refAndDeref_null_QSP_QString() RESULT : tst_QSharedPointer::refAndDeref_null_QSP_QString(): 0.0000025 msecs per iteration (total: 86, iterations: 33554432) PASS : tst_QSharedPointer::refAndDeref_null_SSP_QString() RESULT : tst_QSharedPointer::refAndDeref_null_SSP_QString(): 0.0000023 msecs per iteration (total: 80, iterations: 33554432) PASS : tst_QSharedPointer::refAndDeref_null_BSP_QString() RESULT : tst_QSharedPointer::refAndDeref_null_BSP_QString(): 0.0000026 msecs per iteration (total: 88, iterations: 33554432) PASS : tst_QSharedPointer::refAndDeref_nonnull_QSP_int() RESULT : tst_QSharedPointer::refAndDeref_nonnull_QSP_int(): 0.000019 msecs per iteration (total: 83, iterations: 4194304) PASS : tst_QSharedPointer::refAndDeref_nonnull_SSP_int() RESULT : tst_QSharedPointer::refAndDeref_nonnull_SSP_int(): 0.000010 msecs per iteration (total: 90, iterations: 8388608) PASS : tst_QSharedPointer::refAndDeref_nonnull_BSP_int() RESULT : tst_QSharedPointer::refAndDeref_nonnull_BSP_int(): 0.0000094 msecs per iteration (total: 79, iterations: 8388608) PASS : tst_QSharedPointer::refAndDeref_nonnull_QSP_QString() RESULT : tst_QSharedPointer::refAndDeref_nonnull_QSP_QString(): 0.000017 msecs per iteration (total: 75, iterations: 4194304) PASS : tst_QSharedPointer::refAndDeref_nonnull_SSP_QString() RESULT : tst_QSharedPointer::refAndDeref_nonnull_SSP_QString(): 0.000010 msecs per iteration (total: 90, iterations: 8388608) PASS : tst_QSharedPointer::refAndDeref_nonnull_BSP_QString() RESULT : tst_QSharedPointer::refAndDeref_nonnull_BSP_QString(): 0.0000091 msecs per iteration (total: 77, iterations: 8388608) PASS : tst_QSharedPointer::threadedRefAndDeref_null_QSP_int() RESULT : tst_QSharedPointer::threadedRefAndDeref_null_QSP_int(): 0.000016 msecs per iteration (total: 68, iterations: 4194304) PASS : tst_QSharedPointer::threadedRefAndDeref_null_SSP_int() RESULT : tst_QSharedPointer::threadedRefAndDeref_null_SSP_int(): 0.000025 msecs per iteration (total: 53, iterations: 2097152) PASS : tst_QSharedPointer::threadedRefAndDeref_null_BSP_int() RESULT : tst_QSharedPointer::threadedRefAndDeref_null_BSP_int(): 0.000027 msecs per iteration (total: 58, iterations: 2097152) PASS : tst_QSharedPointer::threadedRefAndDeref_null_QSP_QString() RESULT : tst_QSharedPointer::threadedRefAndDeref_null_QSP_QString(): 0.000016 msecs per iteration (total: 71, iterations: 4194304) PASS : tst_QSharedPointer::threadedRefAndDeref_null_SSP_QString() RESULT : tst_QSharedPointer::threadedRefAndDeref_null_SSP_QString(): 0.000027 msecs per iteration (total: 58, iterations: 2097152) PASS : tst_QSharedPointer::threadedRefAndDeref_null_BSP_QString() RESULT : tst_QSharedPointer::threadedRefAndDeref_null_BSP_QString(): 0.000017 msecs per iteration (total: 73, iterations: 4194304) PASS : tst_QSharedPointer::threadedRefAndDeref_nonnull_QSP_int() RESULT : tst_QSharedPointer::threadedRefAndDeref_nonnull_QSP_int(): 0.00073 msecs per iteration (total: 96, iterations: 131072) PASS : tst_QSharedPointer::threadedRefAndDeref_nonnull_SSP_int() RESULT : tst_QSharedPointer::threadedRefAndDeref_nonnull_SSP_int(): 0.000408 msecs per iteration (total: 107, iterations: 262144) PASS : tst_QSharedPointer::threadedRefAndDeref_nonnull_BSP_int() RESULT : tst_QSharedPointer::threadedRefAndDeref_nonnull_BSP_int(): 0.00033 msecs per iteration (total: 89, iterations: 262144) PASS : tst_QSharedPointer::threadedRefAndDeref_nonnull_QSP_QString() RESULT : tst_QSharedPointer::threadedRefAndDeref_nonnull_QSP_QString(): 0.000877 msecs per iteration (total: 115, iterations: 131072) PASS : tst_QSharedPointer::threadedRefAndDeref_nonnull_SSP_QString() RESULT : tst_QSharedPointer::threadedRefAndDeref_nonnull_SSP_QString(): 0.00033 msecs per iteration (total: 89, iterations: 262144) PASS : tst_QSharedPointer::threadedRefAndDeref_nonnull_BSP_QString() RESULT : tst_QSharedPointer::threadedRefAndDeref_nonnull_BSP_QString(): 0.000385 msecs per iteration (total: 101, iterations: 262144) PASS : tst_QSharedPointer::cleanupTestCase() Totals: 26 passed, 0 failed, 0 skipped, 0 blacklisted, 7995ms ********* Finished testing of tst_QSharedPointer ********* Change-Id: I0bed70142ffdbde6898ec0e27cb470b50fc0e97d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Purge empty methods from tst_QSqlRecordEdward Welbourne2021-07-231-17/+0
| | | | | | | There's no point mentioning empty init(), constructor and destructor. Change-Id: I0b820f62fd46a955aae891adfc68ca366ca60672 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Select PostgreSQL-only data, rather than filtering in the testEdward Welbourne2021-07-231-19/+17
| | | | | | | | | | | | Two QSqlRecord benchmarks that are only relevant for PostgreSQL were being run for all backends, without producing useful results for the others. Since the test is data-driven and the generic data-table code can take a backend-name to decide which to include, pass a suitable string to the generic data method instead, so that we now simply skip these tests (and say we're doing so) rather than "passing" them. Change-Id: I2223c16007a7095a9cadd13a9b2d46813507a35f Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Rename QSqlRecord benchmark's source file to match its test nameEdward Welbourne2021-07-232-2/+2
| | | | | Change-Id: I580f185b3bbe283dfa2f43bbc986233d01219814 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Make QSqlRecord benchmarks non-fatuousEdward Welbourne2021-07-231-2/+6
| | | | | | | | | | | | | | Because QBENCHMARK re-runs its block repeatedly, to get sensible data, the block needs to actually do something when repeated. Since these tests had blocks that looped while (qry.next()), they left qry at its end state, so such repeats tested nothing. Use seek(0) at the start of each cycle to actually do the work repeatedly when the block is repeated. As a drive-by, split a long line. Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-91713 Change-Id: Id46f77dc5e71335871af79ff61e1980b5f636179 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Halve the data-set size of tst_QSqlRecord::benchmarkRecord()Edward Welbourne2021-07-231-1/+2
| | | | | | | | | | At 1000, the set-up was taking longer than the five minutes QtTestLib's WatchDog allows, so the test got killed. Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-91713 Change-Id: Ia3c85b223fc917ad5817364505cbffe50d67ddc6 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Convert QLocalSocket benchmark to use QTestEventLoopEdward Welbourne2021-07-231-10/+17
| | | | | | | | | | | Now that this event loop pays attention to test failures, we can avoid the time-outs that used to happen on test failure. Also check for premature failures (but don't return early, so we can shut down the server gracefully) and give the event-loops sensible time-outs. Task-number: QTBUG-91713 Change-Id: Ib895a5fba0f22654c7fecf996f23649a4b5ce0de Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* Assert some more things we can be sure of in the QMap benchmarkEdward Welbourne2021-07-231-0/+17
| | | | | | | | | Just in case the test isn't testing what we think it is. One of my earlier changes didn't until this told me about it. Change-Id: Idd6f415d543509cabb3a64219736bb43e60a70ef Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QMap benchmark: use unsigned accumulators and check themEdward Welbourne2021-07-231-4/+12
| | | | | | | | | | | | | | | | | | | The sum of the first 100000 naturals is more than 2^32, so using an int accumulator to collect the values is susceptible to overflow, which is UB for signed integral types. So switch to an unsigned type. We don't care about the actual sum, only having the various map entries we fetch "used". Since unsigned arithmetic is well-defined even when it overflows, we can calculate the expected sum and verify it, to ensure that no matter how clever the optimizer, it won't throw out the accumulator as written but not read (and then optimize out all the tested code). As a drive-by, rename one of the accumulators to match the rest. Change-Id: I93a2825247c96ca88fe52fdb7ce1e5456eebad54 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Rename QMap benchmark source file to match test nameEdward Welbourne2021-07-232-2/+2
| | | | | | | | s/main/tst_bench_qmap/g Change-Id: Ic520254f5b5f946f4eaa234352317749a9a7301f Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>