summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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>
* Add benchmarks for QString::numberMårten Nordheim2021-07-222-3/+133
| | | | | | | | | While we're here: - remove the GCC precondition for compiling this benchmark. Task-number: QTBUG-88484 Change-Id: I14f3ea7e4708e274d032a6297e9d4a87ae5dc1c0 Reviewed-by: Edward Welbourne <edward.welbourne@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>
* QString benchmark: rename the source fileMårten Nordheim2021-07-212-2/+2
| | | | | | | 'main.cpp' is quite generic when using search to look for it. Change-Id: I547ba16a11db8efb7d4410b94343b03d30da6513 Reviewed-by: Edward Welbourne <edward.welbourne@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>
* Rename QFile benchmark's source file to tst_bench_qfile.cppEdward Welbourne2021-07-192-2/+2
| | | | | | | Let's have fewer files with the same main.cpp name. Change-Id: Iad94478affcca73a25ed29ba4380f1b3ca4f329d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Drop pointless parentheses from round case labelsEdward Welbourne2021-07-191-20/+20
| | | | | Change-Id: I5339523f83aea4d91aaec9bd2570b225287ae23a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace Q_FOREACH() with ranged-for loopsEdward Welbourne2021-07-191-20/+16
| | | | | | | | | In the process, fix two coding-style violations: while loops whose empty bodies were given as a semicolon rather than as empty braces. Also ditch some spurious braces. Change-Id: I2734077f4f54985c4e8d81f846c1fa6fac4f529d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFile benchmark: only set up and tear down the data directory onceEdward Welbourne2021-07-191-99/+73
| | | | | | | | | | | | | | | | | | | | | | | | None of the tests modify the data, so there's no risk that one test will cause another to fail via that. We can thus avoid the repeated cost of that set-up and teardown, which was done repeatedly for each test function since benchmarks get run repeatedly if they're quick. Use QTemporaryDir to manage the test data, so that it's tidied away automagically, instead of trying to tidy up at the end of each test (which was, of course, skipped if the test failed). As drive-bys, fix a typo in a QFAIL()'s message, change some C casts that silently bulldozed const away to reinterpret_cast<>s with the const qualifier and turn some heap buffers into stack buffers to save the need to delete [] them at the end of their tests (also skipped on failure). Inspired by a kindred change by Andreas Buhr and a suggestion on its review by Friedemann Kleint. Pick-to: 6.2 6.1 5.15 Change-Id: I6067eb35babfbac02990ef39817b0d5122f563cd Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Skip trailing space on ends of QFile benchmark namesEdward Welbourne2021-07-161-3/+6
| | | | | | | | | | They were there to make it easier to build the names. Avoiding them wasn't exactly hard. Change-Id: I9e353644d81f80d69ecf73fe4fa875948ccbc2c9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* QFile benchmark: purge fatuous function, inline several moreEdward Welbourne2021-07-161-39/+8
| | | | | | | | | The empty cleanupTestCase() was just clutter. Various tests that shared a common implementation (using different data) might just as well be inline in the class body. Change-Id: I5046d7e6ad5a6425df9f9e0a0a705e229d9d0717 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFile benchmark: fix -Wunused-resultMarc Mutz2021-07-151-2/+2
| | | | | | Change-Id: Ibc8a146eb9eb6338f661f7813813ea0a0264c759 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@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>
* Fix qdbusperformance and qprocess benchmarksEdward Welbourne2021-07-153-6/+12
| | | | | | | | | | | | | | | The tests failed because they couldn't find the servers they needed to run. The dbus server wasn't being built, due to mis-configured CMake config; fixed dbus server CMake config. Once built, the servers werent at the paths relative to the test binaries that were given in the test source files, because the test binary was in the test/ sub-directory. The dbus test just needed a ../ on its path; the qprocess one also needed its path wrapped in QFINDTESTDATA(), and a ".exe" suffix on MS. Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-91713 Change-Id: I5ace23a5815575bbf88ea88e0b16afc7b8ba6a08 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QLocalSocket benchmark: improve connectivity and error reportingAlex Trotsenko2021-07-151-0/+4
| | | | | | | | | | | For nonblocking Unix domain sockets the connection may not be completed immediately. So, add a blocking call to waitForConnected() to improve test stability. Also, explain a possible reason that cause the connection to fail on Unix. Task-number: QTBUG-91713 Change-Id: If34070f2383fd0c854e2707c734fe5da4bda1b42 Reviewed-by: Mårten Nordheim <marten.nordheim@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>
* QLocalSocket benchmark: Report server error string if listen() failsEdward Welbourne2021-07-151-1/+3
| | | | | | | | | | | Including the error string gives whoever's running the test at least some clue what's going wrong. One day it might even give them the information they need to get later runs of the server past this hurdle. Task-number: QTBUG-95136 Change-Id: I5d67097339f1db78dfb7ba2ed4357121396977dd Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* QStringList benchmark: fix the [[nodiscard]] warningsMarc Mutz2021-07-131-3/+3
| | | | | | Change-Id: I06572824e7037d8b14383b8867059aa2df493c82 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>