Commit Graph

611 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov
44a7412795 Remove checks for C++ standard versions C++17 and below
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>
2021-10-01 02:46:09 +02:00
Chen Wei
73a997823c Deprecate constructing QString from a pointer
Change-Id: Ib37775567c12f23b220825c76a32b6c17ca5264b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-07 18:53:37 +08:00
Edward Welbourne
c8144681aa Add note to QList benchmark about known bug
Task-number: QTBUG-95096
Change-Id: I08f789f2e6ed70507da18e629140404f09bfae12
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-30 19:21:08 +02:00
Edward Welbourne
9004a2412b Standardise layout and naming in corelib benchmarks
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>
2021-08-30 19:21:08 +02:00
Edward Welbourne
9935dfe289 New QByteArray::toU?LongLong() benchmark
Change-Id: Ic0581dd5625f9b2750646c73dc80d89741d97a1d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-27 18:44:50 +02:00
Edward Welbourne
eec25c7807 Fix the (currently unbuilt) qdir/tree/ benchmark
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>
2021-08-23 14:39:44 +02:00
Edward Welbourne
497b9fd1ce Add benchmark for QByteArray::toPercentEncoding()
Change-Id: If822bb3b9c6623137f27b6624598530432246ed2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-19 15:06:49 +02:00
Marc Mutz
01fdc17493 Add benchmark for QMetaEnum
Change-Id: If57f00b14713f2083260a00fd833da62d6f1cd57
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-16 19:26:29 +02:00
Volker Hilsheimer
761f32ae2a Fix some compiler warnings from deprecated QFont constructor
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>
2021-08-11 21:50:51 +02:00
Tor Arne Vestbø
bef57b317f testlib: Deprecate QWARN() in favor of qWarning()
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>
2021-08-04 19:31:51 +02:00
Mårten Nordheim
d179ec6ca4 QString benchmark: don't use %ls
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>
2021-07-29 10:42:36 +02:00
Marc Mutz
3a72496b5c tests: fix some -Wvolatile
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>
2021-07-28 17:50:09 +02:00
Marc Mutz
25fff849e8 QDirIterator: add nextFileInfo()
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>
2021-07-28 15:16:42 +02:00
Marc Mutz
8e0c2d7d22 Fix various -Wdeprecated-enum-float-conversions around the code
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>
2021-07-27 14:58:41 +02:00
Marc Mutz
18113e22e9 Add a benchmark for QSharedPointer
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>
2021-07-27 14:58:41 +02:00
Edward Welbourne
1ae4c56ceb Purge empty methods from tst_QSqlRecord
There's no point mentioning empty init(), constructor and destructor.

Change-Id: I0b820f62fd46a955aae891adfc68ca366ca60672
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-07-23 20:35:02 +02:00
Edward Welbourne
415457302b Select PostgreSQL-only data, rather than filtering in the test
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>
2021-07-23 20:35:02 +02:00
Edward Welbourne
54e50792da Rename QSqlRecord benchmark's source file to match its test name
Change-Id: I580f185b3bbe283dfa2f43bbc986233d01219814
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-07-23 20:35:01 +02:00
Edward Welbourne
432eab3bc0 Make QSqlRecord benchmarks non-fatuous
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>
2021-07-23 20:35:01 +02:00
Edward Welbourne
346bdc6143 Halve the data-set size of tst_QSqlRecord::benchmarkRecord()
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>
2021-07-23 20:35:00 +02:00
Edward Welbourne
328f22561d Convert QLocalSocket benchmark to use QTestEventLoop
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>
2021-07-23 19:48:59 +02:00
Edward Welbourne
ebae6e2041 Assert some more things we can be sure of in the QMap benchmark
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>
2021-07-23 17:19:18 +02:00
Edward Welbourne
23434f487b QMap benchmark: use unsigned accumulators and check them
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>
2021-07-23 17:19:12 +02:00
Edward Welbourne
d0f9743d3b Rename QMap benchmark source file to match test name
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>
2021-07-23 17:19:04 +02:00
Edward Welbourne
b3e2e5f5b9 Give symbolic names to the sizes of data-sets tested in QMap benchmark
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>
2021-07-23 17:18:59 +02:00
Mårten Nordheim
640c5ca088 Add benchmarks for QString::number
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>
2021-07-22 23:01:41 +02:00
Edward Welbourne
b5950f6aff Use QChar::fromUcs4(i) rather than QChar(i) on out-of-range i
Follow-up to commit 915be6606e, 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>
2021-07-22 18:49:16 +02:00
Edward Welbourne
2e24ee02af Don't slow down a QMap benchmark by growing a megabyte-long string
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>
2021-07-21 20:33:24 +02:00
Mårten Nordheim
ec0b44003b QString benchmark: rename the source file
'main.cpp' is quite generic when using search to look for it.

Change-Id: I547ba16a11db8efb7d4410b94343b03d30da6513
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-07-21 17:20:35 +02:00
Edward Welbourne
7a4bf7bd05 Rename QVector benchmark and its main.cpp for consistency
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>
2021-07-19 18:55:51 +02:00
Edward Welbourne
a87411cefa Clean up old QVector benchmark
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>
2021-07-19 16:55:51 +00:00
Edward Welbourne
406bb11a4e Suppress a broken benchmark comparing QVector to std::vector
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>
2021-07-19 18:55:51 +02:00
Edward Welbourne
d115f17cb8 Rename QFile benchmark's source file to tst_bench_qfile.cpp
Let's have fewer files with the same main.cpp name.

Change-Id: Iad94478affcca73a25ed29ba4380f1b3ca4f329d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-07-19 11:31:59 +02:00
Edward Welbourne
ec7b836455 Drop pointless parentheses from round case labels
Change-Id: I5339523f83aea4d91aaec9bd2570b225287ae23a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-07-19 11:31:55 +02:00
Edward Welbourne
31e094922c Replace Q_FOREACH() with ranged-for loops
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>
2021-07-19 11:31:46 +02:00
Edward Welbourne
e1b3a46302 QFile benchmark: only set up and tear down the data directory once
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>
2021-07-19 11:31:38 +02:00
Edward Welbourne
aff8d83512 Skip trailing space on ends of QFile benchmark names
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>
2021-07-16 17:01:24 +02:00
Edward Welbourne
cc7e0b5c2c QFile benchmark: purge fatuous function, inline several more
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>
2021-07-16 17:01:24 +02:00
Marc Mutz
d79b3cbdd3 QFile benchmark: fix -Wunused-result
Change-Id: Ibc8a146eb9eb6338f661f7813813ea0a0264c759
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-07-15 17:12:56 +02:00
Edward Welbourne
c61d18716f Limit some QList benchmark data-set sizes to avoid time-outs
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>
2021-07-15 17:06:54 +02:00
Edward Welbourne
bf99c2b62b Fix qdbusperformance and qprocess benchmarks
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>
2021-07-15 15:06:54 +00:00
Alex Trotsenko
ac40875ba7 QLocalSocket benchmark: improve connectivity and error reporting
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>
2021-07-15 18:06:54 +03:00
Edward Welbourne
19f522c74a QList benchmark: inline the removAll tests to match most others
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>
2021-07-15 17:06:53 +02:00
Edward Welbourne
65ac651f12 QLocalSocket benchmark: Report server error string if listen() fails
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>
2021-07-15 17:06:53 +02:00
Marc Mutz
9ee4290293 QStringList benchmark: fix the [[nodiscard]] warnings
Change-Id: I06572824e7037d8b14383b8867059aa2df493c82
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-13 16:57:31 +02:00
Marc Mutz
521e801b52 QString benchmark: fix the [[nodiscard]] warnings
Change-Id: I75941c295ba7d0a9bff5f12b49db28875b97c62a
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-07-09 17:59:01 +02:00
Edward Welbourne
f1d40ca5e9 Unify and clean up two identical tst_qfile::*_data() functions
Convert newRow() to addRow() to simplify formatting, use a ranged-for
iteration, take out a common factor of 1024, use QByteArray instead of
roundtripping ASCII via Unicode, and break some long lines.

Change-Id: I052730a71fb74f40a0dbd0695dcc286bc39896fb
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2021-07-07 19:36:49 +02:00
Edward Welbourne
1cabfd1680 Move QSKIP()s to _data() functions in QFile benchmark
Skipping once in the data function is the clean way to do this. Saves
setting up dummy data just so as to skip it, or setting up real data
and then skippin on each row.

Change-Id: I1666d134b6f206e8055fbbc5efd2e2116431a9c1
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2021-07-07 19:36:49 +02:00
Edward Welbourne
f74b2e3479 QFile benchmark: always use Unbuffered for QFSFileEngine tests
Support for buffered usage with QFSFileEngine was dropped in 5.10;
trying to use it triggers an assert.

Task-number: QTBUG-91713
Pick-to: 5.15 6.1 6.2
Change-Id: I5f46e9f793310538344b96bf2efbeba34098de83
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-07-06 13:50:55 +02:00
Edward Welbourne
74e9b77f4f Fix QDirIterator benchmark to actually find its test data
The benchmark had a hard-coded path on MS and needed an environment
variable set otherwise; neither sounds like a good approach, when
testlib defines a variable that tells us the test's source directory,
a clearly superior way to find things in our source directories.

In the process, replace exit()ing on failure to get a path with a
QSKIP() so that the test at least fails gracefully if it ever can't
find its data. (Using QFAIL() left it with no rows but still trying to
run the test, leading to an assert failure.)

Pick-to: 6.2 6.1 5.15
Task-number: QTBUG-91713
Change-Id: I1bd5561971239bb838bcf6c24bcdf1d07c81a657
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-07-06 13:50:55 +02:00