summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* qHash: implement an AES hasher for QLatin1StringViewThiago Macieira2024-03-123-11/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's the same aeshash() as before, except we're passing a template parameter to indicate whether to read half and then zero-extend the data. That is, it will perform a conversion from Latin1 on the fly. When running in zero-extending mode, the length parameters are actually doubled (counting the number of UTF-16 code units) and we then divide again by 2 when advancing. The implementation should have the following performance characteristics: * QLatin1StringView now will be roughly half as fast as Qt 6.7 * QLatin1StringView now will be roughly as fast as QStringView For the aeshash128() in default builds of QtCore (will use SSE4.1), the long loop (32 characters or more) is: QStringView QLatin1StringView movdqu -0x20(%rax),%xmm4 | pmovzxbw -0x10(%rdx),%xmm2 movdqu -0x10(%rax),%xmm5 | pmovzxbw -0x8(%rdx),%xmm3 add $0x20,%rax | add $0x10,%rdx pxor %xmm4,%xmm0 | pxor %xmm2,%xmm0 pxor %xmm5,%xmm1 | pxor %xmm3,%xmm1 aesenc %xmm0,%xmm0 aesenc %xmm0,%xmm0 aesenc %xmm1,%xmm1 aesenc %xmm1,%xmm1 aesenc %xmm0,%xmm0 aesenc %xmm0,%xmm0 aesenc %xmm1,%xmm1 aesenc %xmm1,%xmm1 The number of instructions is identical, but there are actually 2 more uops per iteration. LLVM-MCA simulation shows this should execute in the same number of cycles on older CPUs that do not have support for VAES (see <https://analysis.godbolt.org/z/x95Mrfrf7>). For the VAES version in aeshash256() and the AVX10 version in aeshash256_256(): QStringView QLatin1StringView vpxor -0x40(%rax),%ymm1,%ym | vpmovzxbw -0x20(%rax),%ymm3 vpxor -0x20(%rax),%ymm0,%ym | vpmovzxbw -0x10(%rax),%ymm2 add $0x40,%rax | add $0x20,%rax | vpxor %ymm3,%ymm0,%ymm0 | vpxor %ymm2,%ymm1,%ymm1 vaesenc %ymm1,%ymm1,%ymm1 < vaesenc %ymm0,%ymm0,%ymm0 vaesenc %ymm0,%ymm0,%ymm0 vaesenc %ymm1,%ymm1,%ymm1 vaesenc %ymm1,%ymm1,%ymm1 vaesenc %ymm0,%ymm0,%ymm0 vaesenc %ymm0,%ymm0,%ymm0 > vaesenc %ymm1,%ymm1,%ymm1 In this case, the increase in number of instructions matches the increase in number of uops. The LLVM-MCA simulation says that the QLatin1StringView version is faster at 11 cycles/iteration vs 14 cyc/it (see <https://analysis.godbolt.org/z/1Gv1coz13>), but that can't be right. Measured performance of CPU cycles, on an Intel Core i9-7940X (Skylake, no VAES support), normalized on the QString performance (QByteArray is used as a stand-in for the performance in Qt 6.7): aeshash | siphash QByteArray QL1SV QString QByteArray QString dictionary 94.5% 79.7% 100.0% 150.5%* 159.8% paths-small 90.2% 93.2% 100.0% 202.8% 290.3% uuids 81.8% 100.7% 100.0% 215.2% 350.7% longstrings 42.5% 100.8% 100.0% 185.7% 353.2% numbers 95.5% 77.9% 100.0% 155.3%* 164.5% On an Intel Core i7-1165G7 (Tiger Lake, capable of VAES and AVX512VL): aeshash | siphash QByteArray QL1SV QString QByteArray QString dictionary 90.0% 91.1% 100.0% 103.3%* 157.1% paths-small 99.4% 104.8% 100.0% 237.5% 358.0% uuids 88.5% 117.6% 100.0% 274.5% 461.7% longstrings 57.4% 111.2% 100.0% 503.0% 974.3% numbers 90.6% 89.7% 100.0% 98.7%* 149.9% On an Intel 4th Generation Xeon Scalable Platinum (Sapphire Rapids, same Golden Cove core as Alder Lake): aeshash | siphash QByteArray QL1SV QString QByteArray QString dictionary 89.9% 102.1% 100.0% 158.1%* 172.7% paths-small 78.0% 89.4% 100.0% 159.4% 258.0% uuids 109.1% 107.9% 100.0% 279.0% 496.3% longstrings 52.1% 112.4% 100.0% 564.4% 1078.3% numbers 85.8% 98.9% 100.0% 152.6%* 190.4% * dictionary contains very short entries (6 characters) * paths-small contains strings of varying length, but very few over 32 * uuids-list contains fixed-length strings (38 characters) * longstrings is the same but 304 characters * numbers also a lot contains very short strings (1 to 6 chars) What this shows: * For short strings, the performance difference is negligible between all three * For longer strings, QLatin1StringView now costs between 7 and 17% more than QString on the tested machines instead of up to ~50% less, except on the older machine (where I think the main QString hashing is suffering from memory bandwidth limitations) * The AES hash implementation is anywhere from 1.6 to 11x faster than Siphash * Murmurhash (marked with asterisk) is much faster than Siphash, but it only managed to beat the AES hash in one test Change-Id: I664b9f014ffc48cbb49bfffd17b045c1811ac0ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Change license for tests filesLucie Gérard2024-02-0417-17/+17
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Bench QSet::uniteMårten Nordheim2024-02-011-0/+68
| | | | | | | | | It was shown to have poor performance compared to contains() and insert(). Pick-to: 6.7 6.6 6.5 Change-Id: I61cfbc8c34e325d677d7954118ef68057df640cb Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* tst_bench_{qhash,qset}: set deterministic seedMårten Nordheim2024-01-232-0/+8
| | | | | | | | | | | | | | There's a lot of variation in the benchmark graphs for QHash presumably caused by variation in seed. Optimally we would set deterministic seed for all benchmarks, but we don't know whether or not it is one until the macro is reached. Pick-to: 6.7 6.6 6.5 Change-Id: I4e412e4d4e2cc65eada94ed123243ed0047dd9cf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark all of Qt as free of Q_FOREACH, except where it isn'tMarc Mutz2023-08-193-0/+6
| | | | | | | | | | | | | | | | | | | | | | The density of Q_FOREACH uses in this and some other modules is still extremely high, too high for anyone to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the #undef QT_NO_FOREACH to indicate that these actually test the macro. Task-number: QTBUG-115839 Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_bench_QCryptographicHash: use resultView()Marc Mutz2023-03-311-3/+3
| | | | | | | | | | | | | | | | | Don't benchmark the creation of the QByteArray from the internal buffer, that's not interesting. Call resultView() instead of result(). On the one hand, this skews comparisons with older benchmark data. OTOH, result() used to be the fastest way to get the result out of QCryptographicHash or QMessageAuthenticationCode, and now it's resultView(), so in a way, it still is a fair comparison. Pick-to: 6.5 Change-Id: I864b2f88f01e426c5d0967f57199e13dd7cb29f8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_bench_QCryptographicHash: port from std::function to qxp::function_refMarc Mutz2023-03-311-3/+2
| | | | | | | | Because we can, and because function_ref is never null. Pick-to: 6.5 Change-Id: If71f98860d72eaa8cf8a93bb3c59a0260d3c7660 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_bench_QCryptographicHash: QSKIP unsupported algorithmsMarc Mutz2023-03-311-0/+19
| | | | | | | | | With the OpenSSL 3 backend, some algorithms may not be available. Skip benchmarking them. Pick-to: 6.5 Change-Id: I1275332993fe15c007410e25acf59f5e3ec27894 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_bench_QCryptographicHash: add benchmarks for QMessageAuthenticationCodeMarc Mutz2023-03-311-0/+80
| | | | | | | | | | | We could add a tst_QMessageAuthenticationCode, but it would have to duplicate a lot of the tst_QCryptographicHash machinery, so just add it here. Pick-to: 6.5 6.2 5.15 Change-Id: Icc60de865c72c5e423cb3be57f58297c522791f7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_bench_QCryptographicHash: swallow result() return valuesMarc Mutz2023-03-231-3/+6
| | | | | | | | | | | As usual, assign them to a [[maybe_unused]] variable, to avoid potential future [[nodiscard]] problems, and to indicate to readers of the code that there's a result that's being returned, we're just not interested in it. Pick-to: 6.5 6.2 Change-Id: I2bd47ca98418092ca885d50a1a6417a21a612a85 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_bench_QCryptographicHash: use QMetaEnum trickMarc Mutz2023-03-231-60/+20
| | | | | | | | | | | | | | | | ... conveniently wrapped in a generator, to not have to keep an algoname() function in sync with QCryptographicHash::Algorithm. The MaxCryptoAlgorithm constant was already stale following the addition of BLAKE2b/s algorithms in 5d69aa3ee1214cf689e2357bff8688f2ff138471. Also make the data-driven tests have an actual Algorithm column (was: int) to minimize casting. Pick-to: 6.5 6.2 5.15 Change-Id: I89a6098e512a72f623fd50a6f88fc351c7bb1418 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_bench_QCryptographicHash: port to QTest::addRow()Marc Mutz2023-03-231-24/+24
| | | | | | | | | Allows using printf-style tag formatting. Pick-to: 6.5 6.2 5.15 Change-Id: Icb8014dd476a32791c662a15b209dbb3bd7d6c96 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace ushort*/uint* with char16_t*/char32_t* in private API [1]Ahmad Samir2023-03-151-1/+1
| | | | | | | Task-number: QTBUG-110403 Pick-to: 6.5 Change-Id: Ie20a831f22212d56659cf3c6940d17134ab5f2c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Silence warning, initialize variables before usingVolker Hilsheimer2023-03-061-2/+2
| | | | | | Pick-to: 6.5 Change-Id: I0e7db95bac48b5d79897402f23157d00c4abbdff Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-172-4/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Update tst_bench_qhash hash functions to use size_tMårten Nordheim2022-09-272-10/+10
| | | | | | | | | | | Pre-requisite for a fix for qHash. The Qt50String inherits from QString and becomes ambiguous once it no longer goes through a catch-all template function because qHash(QString, size_t) has a better match for the second argument. Pick-to: 6.2 6.4 Change-Id: I23c7afb1b3aa167d40dc4838e82b7763de015f6b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2314-14/+14
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0314-0/+42
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-2813-13/+13
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* tst_bench_shared_ptr: fix build with BOOST_NO_EXCEPTIONSMarc Mutz2022-06-221-0/+13
| | | | | | | | | | | | | | | | | If, for whatever reason, BOOST_NO_EXCEPTIONS is defined, the user of the Boost libraries is supposed to provide a definition of boost::throw_exception, which we didn't. We used to run into this only on ubsan builds, but it seems we now have the problem on a regular Ubuntu 22.04 build, too (cf. bugreport). Fix by adding the necessary definitions. Fixes: QTBUG-104083 Pick-to: 6.4 6.3 Change-Id: I9b061a158a5b77e8d286bd7b40312e5bc63ee8de Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1617-460/+35
| | | | | | | | | | | | | 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>
* benchmarks: fix deprecation warningsMarc Mutz2022-04-061-2/+2
| | | | | | | | | - 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>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+2
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@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>
* 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-3023-102/+73
| | | | | | | | | | | | | | | 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>
* 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>
* 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>
* Give symbolic names to the sizes of data-sets tested in QMap benchmarkEdward Welbourne2021-07-231-24/+27
| | | | | | | | | Mostly so that I can put comments on them to indicate why some tests are bigger and others not so big. Change-Id: I633ceb264aa96ee8f5345e3f342a518e8ae4838b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use QChar::fromUcs4(i) rather than QChar(i) on out-of-range iEdward Welbourne2021-07-221-16/+28
| | | | | | | | | | | | | | | | | | | Follow-up to commit 915be6606ead25f4fbbbcb2687b33cf22a955177, catching some benchmarks that took for granted they can assign an arbitrary int to QChar. Since 6.0 this has triggered an assertion. Given the choice between limiting the range (from 100000 to 0x10000) and actually handling the out-of-range values as UCS-4 data, the latter seemed like a more interesting test. At the same time, take the construction of the strings out of the loop, as that's not a QMap performance matter, it's a QString one. Pick-to: 6.1 6.2 Task-number: QTBUG-91713 Change-Id: Id6abab08b5c879f0f764350f66d6aa1dd9f1620a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Don't slow down a QMap benchmark by growing a megabyte-long stringEdward Welbourne2021-07-211-1/+1
| | | | | | | | | | | | | | Change a += to simple assignment where it's string arithmetic (a hundred thousand concatenations of "Hello World" add up to more than a megabyte, in an incremental growth that's going to dominate the QMap operations we were meant to be benchmarking) and the only reason for it is to avoid an unused result warning. Accumulating int values is harmless, but strings are another story ! Pick-to: 6.1 6.2 Task-number: QTBUG-91713 Change-Id: Ib0dc131b0cc75fea23998afc0300e8cb60076c7e Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Rename QVector benchmark and its main.cpp for consistencyEdward Welbourne2021-07-192-4/+4
| | | | | | | | | The usual pattern (at least in corelib) is tst_bench_[lowercased class-name] for the test and the same with .cpp for the source-file name. So s/(main|tst_bench_vector)/tst_bench_qvector/g Change-Id: Ic9bd3ac87adfaec189409c2259cc674ebcec602c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clean up old QVector benchmarkEdward Welbourne2021-07-193-225/+68
| | | | | | | | | | | | Purge comments showing assember from an antique g++ version, skip #if-ery that's always been on, so makes no difference, rename two single-letter variables shared between files, move some extern declarations to a header, wrap parts of a source file in QT_{BEGIN,END}_NAMESPACE, add a TODO against an antique commented out #if-ery kludge. Change-Id: Ic4781960e0c9838027c21d3d392a50f29598132c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Suppress a broken benchmark comparing QVector to std::vectorEdward Welbourne2021-07-192-6/+15
| | | | | | | | | | | | | | | | The test constructs an ersatz object with which to overwrite a QVector's internals, but based it on Qt 5's memory layout. Since Qt 6 completely rearranged that memory layout, the test now crashes (or, in a debug build, trips over an out-of-bounds assertion). So suppress the test until those who perpetrated it and/or the reworking of QVector's internals can work out how to fix it. That way, QA can at least run the benchmark without crashing. Task-number: QTBUG-95061 Pick-to: 6.2 Change-Id: I0e8c8d58f2002497f6e29d0ad25f840e207704a4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Limit some QList benchmark data-set sizes to avoid time-outsEdward Welbourne2021-07-151-15/+17
| | | | | | | | | | | The watch-dog timer was killing some tests, that take time quadratic in the size of the data to test on, on their test-cases with larger data-set sizes. Enable tuning of the data-table creation to leave off the larger data-sets for thse tests. Task-number: QTBUG-91713 Change-Id: I9f462f4f2ba03c6518486a26361aa2b847322f8c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QList benchmark: inline the removAll tests to match most othersEdward Welbourne2021-07-151-53/+23
| | | | | | | | | | | | | | It may be the hobgoblin of little minds, but consistency makes code easier to read. Turn the implementation test into a method of the class, like all the others, and rename it to match the common pattern. In the process, eliminate the data-column that was constant, use simpler expressions for the lists whose entries are all the same and Split some long lines. The test still fails, as it did previously. Change-Id: Ic2d6db1edc0bbafad91cd732babcbc129c430b8f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QList benchmark: fix annoying -Wdeprecated-copy warningMarc Mutz2021-06-301-0/+2
| | | | | | | | | | MyPrimitive has a copy ctor but lacked a copy assignment operator, leading to above-mentioned warning. Fix by supplying the missing special member function. Change-Id: Icd0c3c12554eb838b5d880ec9a649d0b5cfc81b7 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Update QList benchmark testsAndrei Golubev2021-04-211-101/+68
| | | | | | | | | | | | | | | | | | | Removed 5.15 specific QVector code, which is unlikely usable now when we are at 6.1+ timeline (that was really only a nice-to-have during 5.15 -> 6.0 transition) Added "remove first" benchmark to track the fast (or not so fast) removal path Updated mid insertion and mid emplace to actually trigger both paths (growing at the beginning and at the end), before it was really using just one side, which is not quite the "mid" way it feels. Also changed mid insertion to actually use the insert algorithm. Seems like insert(i, t) calls emplace under the hood at least from the visual introspection Change-Id: I01b82cfa0ae38d481ea7362947f3607d757bf5d0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some warningsAndreas Buhr2021-03-293-9/+25
| | | | | Change-Id: I546300b4e630a2234c83c03ece65a08f4c8652d2 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix compiler warning: initialize variableVolker Hilsheimer2021-02-111-2/+2
| | | | | | | The initialization happens outside the bechmarking loop. Change-Id: Id661fa2f995e964277a5c388b8fac13ff8687d92 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove qmake project files for benchmarksJoerg Bornemann2021-02-0113-81/+0
| | | | | | | | Also remove tests/tests.pro that would be empty without the benchmarks. Change-Id: Iaf92a729d1286b3e0c03bf9f877b59e1d83708e6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-223-3/+3
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix warnings about unused variables in benchmarksAndreas Buhr2020-11-301-0/+1
| | | | | | | | | This patch removes two unused variables and marks one unused, fixing three warnings. Change-Id: I71f59839452590b82ffb5459a968f06bd434fb9a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>