749 Commits

Author SHA1 Message Date
Audun Sutterud
4623def5fb Rename QDecompressHelper benchmark
The convention is to start the benchmark names with the "tst_bench_"
prefix. This makes it easier to detect the benchmark in tools, such as
the Core Benchmarks Runner.

Change-Id: I2dcebb6cef0aba4133c4135462e8d76387b776bf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-21 20:36:55 +02:00
Thiago Macieira
b10c7b1680 qtbase: use qHashMulti & qHashRange instead of QHashCombine
If we have no specific need for the private QHashCombine class, use the
front-end functions. For headers, we do have a need: we prefer
QHashCombine because it compiles faster.

Change-Id: I73578ea802d3b905a53bfffd504c20af0ca96cf8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-09 16:54:13 -07:00
Edward Welbourne
8c086ce832 Correct value of Avogadro's constant used in a test
It doesn't matter at all, but it's now got a defined value, so use it.

Change-Id: Id8e734cd81624a3d4c139b2639381e3f0b162db4
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-05-07 10:23:37 +02:00
Matthias Rauter
355e0d85eb Remove debug flag from benchmark
If debug symbols are needed, then pass the respective flag to the
configure script.

Pick-to: 6.9 6.8
Change-Id: I99db92bdd5b7eb896e0d592117a8f218467a4bd7
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-29 11:02:46 +00:00
Giuseppe D'Angelo
b12a5bf41a tst_qdbusperformance: include what you use (QElapsedTimer)
Pick-to: 6.9 6.8 6.5
Change-Id: I2f880d4ad38f5f3c509c8ddcdad59108d915517b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-26 16:43:21 +01:00
Milian Wolff
1f0bcec874 Add maybe_unused in benchmark to guard against nodiscard in the future
Requested by Marc Mutz when adding the utc() benchmark.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I6f97f9e4dab07d10718280b4fb7ac158e42b8d67
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-01 21:44:15 +01:00
Milian Wolff
29c7beac2e Add a benchmark for QTimeZone::utc
On my machine this gives me:

```
********* Start testing of tst_QTimeZone *********
Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20250207), arch unknown
PASS   : tst_QTimeZone::initTestCase()
PASS   : tst_QTimeZone::utc()
RESULT : tst_QTimeZone::utc():
     358.686871 nsecs per iteration (total: 358,686,513, iterations: 999999)
     896.524312 CPU cycles per iteration, 2,5 GHz (total: 896,523,416, iterations: 999999)
     2,227.000427 instructions per iteration, 2,484 instr/cycle (total: 2,226,998,200, iterations: 999999)
     560.000375 branch instructions per iteration, 1,56 G/sec (total: 559,999,815, iterations: 999999)
PASS   : tst_QTimeZone::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 374ms
********* Finished testing of tst_QTimeZone *********
```

Profiling shows some quite unexpected code paths that
I will try to optimize in follow-up patches. Note that
this function can be called frequently when deserializing
QDateTime over a QDataStream e.g. - I have stumbled over
it while profiling some KDE PIM code in akonadi.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I7439df53ae8512c766f63cb4b0d4f33d14aa3a01
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-01 21:44:10 +01:00
Eirik Aavitsland
91f502a7d6 Add QPainterPath::trimmed(), returns a slice of a path by length
Path trimming is used in vector graphics and design.

Change-Id: Id5f32b570182f0e8f790835b2fbeb28b3432e40d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-28 17:18:28 +01:00
Marc Mutz
3070efb64a QCbor/JsonValue: add toStringView()
This is like toString(), but returns a view on the underlying string
data (which may be US-ASCII (= L1), UTF-8, or UTF-16, so the return
value is QASV).

Use it around the code a bit.

Benchmark results on my machine (with -perf -iterations 1000):

  PASS   : BenchmarkQtJson::iteratorKey()
  RESULT : BenchmarkQtJson::iteratorKey():
     78,268.426 nsecs per iteration (total: 78,268,427, iterations: 1000)
     349,458.080 CPU cycles per iteration, 4,46 GHz (total: 349,458,080, iterations: 1000)
     780,327.957 instructions per iteration, 2,233 instr/cycle (total: 780,327,957, iterations: 1000)
     173,511.019 branch instructions per iteration, 2,22 G/sec (total: 173,511,020, iterations: 1000)
  PASS   : BenchmarkQtJson::iteratorKeyValueView()
  RESULT : BenchmarkQtJson::iteratorKeyValueView():
     58,424.756 nsecs per iteration (total: 58,424,756, iterations: 1000)
     267,176.603 CPU cycles per iteration, 4,57 GHz (total: 267,176,604, iterations: 1000)
     614,805.388 instructions per iteration, 2,301 instr/cycle (total: 614,805,389, iterations: 1000)
     140,681.105 branch instructions per iteration, 2,41 G/sec (total: 140,681,106, iterations: 1000)
  PASS   : BenchmarkQtJson::iteratorKeyView()
  RESULT : BenchmarkQtJson::iteratorKeyView():
     44,060.925 nsecs per iteration (total: 44,060,925, iterations: 1000)
     196,344.233 CPU cycles per iteration, 4,46 GHz (total: 196,344,233, iterations: 1000)
     426,631.322 instructions per iteration, 2,173 instr/cycle (total: 426,631,323, iterations: 1000)
     93,703.100 branch instructions per iteration, 2,13 G/sec (total: 93,703,101, iterations: 1000)
  PASS   : BenchmarkQtJson::iteratorKeyViewValueView()
  RESULT : BenchmarkQtJson::iteratorKeyViewValueView():
     29,205.569 nsecs per iteration (total: 29,205,570, iterations: 1000)
     131,089.040 CPU cycles per iteration, 4,49 GHz (total: 131,089,041, iterations: 1000)
     258,529.469 instructions per iteration, 1,972 instr/cycle (total: 258,529,469, iterations: 1000)
     60,875.631 branch instructions per iteration, 2,08 G/sec (total: 60,875,631, iterations: 1000)

[ChangeLog][QtCore][QCborValue/QJsonValue] Add toStringView() method.

Fixes: QTBUG-133688
Change-Id: I4200035e995426f1cce46a73a429921a0cd56c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-20 18:02:45 +01:00
Eirik Aavitsland
90247966a7 QPainterPath: Add option to cache calculations
Speeds up repeated calls to length and percentage functions.

Change-Id: I357732e35de648e7da07ad492e58d5b94c2c0870
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-19 15:50:26 +01:00
Eirik Aavitsland
ff7221c677 QPainterPath: Extend autotests for length and percentage functions
Also add a benchmark test for them.

Change-Id: Icc44f54786048550d0a96fd0d1acd3801eaca132
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-19 15:50:26 +01:00
Marc Mutz
bbdbcb2eba QJsonObject::iterator: add keyView()
Unlike CBOR maps, JSON objects can only have string keys, but, like
CBOR, they are internally stored as either US-ASCII (ie. Latin-1),
UTF-8, or UTF-16, so in order to return a view on the internal
storage, QAnyStringView is the perfect fit.

Add (const_)iterator::keyView() and add a benchmark, prepared for
testing a similar change to the value side of things.

Results (fastest each of ten runs) on my machine suggest a 40%
speedup:

  PASS   : BenchmarkQtJson::iteratorKey()
  RESULT : BenchmarkQtJson::iteratorKey():
       0.071 msecs per iteration (total: 73, iterations: 1024)
  PASS   : BenchmarkQtJson::iteratorKeyView()
  RESULT : BenchmarkQtJson::iteratorKeyView():
       0.042 msecs per iteration (total: 87, iterations: 2048)

[ChangeLog][QtCore][QJsonObject] Added keyView() methods to iterator
and const_iterator, allowing zero-copy inspection of the key().

Task-number: QTBUG-133688
Change-Id: I0ccedaf8a4fa41125b12bdbab5bea3bd2468d9a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-12 00:45:13 +01:00
Marc Mutz
5b52814d64 BenchmarkQtJson: print errorString() on QFile::open() failure
Amends 1c3ee86f183d46709c070ccd44970e05dc70f83d.

Pick-to: 6.9 6.8 6.5
Change-Id: Iaffdbd43fc182a46e1280bc7e023083bbea4a285
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-11 08:07:33 +01:00
Volker Hilsheimer
1c3ee86f18 Fix warnings in benchmarks from QFile::open being [[nodiscard]]
Change-Id: I8a80af3614a92645be2d64d02ce81e9d263468c8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-01 02:44:03 +01:00
Lucie Gérard
7cb90e1563 Make module ready for source SBOM checking
This includes:
- turning VERIFY_SOURCE_SBOM ON
- adding exception to the licenseRule.json files
- correcting the licensing given via REUSE.toml files
- renaming license files not located in LICENSES folder.
They need to be named LICENSE. to be ignored by reuse and
excluded from the source SBOM. The name are updated in the
corresponding qt_attribution.json

A lot of files are skipped during the license test,
but all are present in the source SBOM.
This is why  correction are needed before turning the
source SBOM check on.

[ChangeLog][Third-Party Code] Renaming the license files with prefix
LICENSE. to have them ignored by reuse tool.

Task-number: QTBUG-131434
Pick-to: 6.9
Change-Id: Iab517215bb10a17357d2d2436bba8d3af76e5cd1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 12:39:22 +01:00
Vlad Zahorodnii
0345b46ac7 Add QKeySequence::fromString() benchmark
An application may need to load shortcuts from the settings at startup,
so QKeySequence::fromString() should be fast enough if there is a lot of
shortcuts.

This change adds a QKeySequence::fromString() benchmark so one could get
partial insight in its performance.

Change-Id: I9e15c0e9a199787189d5076a41154f127d2930a3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-22 22:35:33 +02:00
Ahmad Samir
db5163dca9 Benchmarks: port Q_FOREACH to ranged-for
Simple cases, all local const containers.

tst_QHash: rename the template parameter to "Str". My eyes saw
"QList<String>", but my brain somehow assumed QList<*Q*String>. You
could argue that I am a bit slow, but it has tricked someone else in
code review, so just rename it for the sake of clarity.

Drive-by, remove braces from one-line for-loop-block.

Task-number: QTBUG-115839
Change-Id: Ia1a56bea7b931efb377ba8c04ee8933561abf341
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-22 05:28:38 +02:00
David Faure
0e2656f937 Fix wrong value for 'noon' in tst_bench_qdatetime
12 hours corresponds to 43,200 seconds, not 43,200 milliseconds.
Amends commit 3febcd6286a3cd22db4f294e7f31a94c07c51fb0

Pick-to: 6.9 6.8 6.5
Change-Id: I2eb3abcab18cd87d51ae70b5fbaeac71a8fcd0a8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-06 19:33:10 +00:00
Ahmad Samir
a1a8e0bb38 tst_QtBench: compile with QT_NO_FOREACH
The container is a member of the unittest, it's not changed by the loop
body or during iteration, so use a ranged-for and std::as_const.

Task-number: QTBUG-115839
Change-Id: I1be75d17ff305bc542cf7b058cc59d70cedc77ad
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:23 +03:00
Ahmad Samir
b5e4657307 tst_bench_qpainter: compile with QT_NO_FOREACH
Use C arrays for data known at compile time.

Drive-by change: verify the two containers that are iterated in tandem
have the same size.

Task-number: QTBUG-115839
Change-Id: I457ddca8aa98e2f15a833a40ff45bd208701bf6b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:23 +03:00
Volker Hilsheimer
97ca5fd859 QPainter: add a benchmark for setPen/setBrush
For the simple case of setting a solid style pen or brush with a color,
which is what we do most in Qt.

Change-Id: Ie90a842ee9638f04941855dfd2e9211235db6cce
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-11-29 21:55:50 +01:00
Volker Hilsheimer
176816f213 QFontEngine: add API to find a glyph by name
The default implementation creates a harfbuzz font and iterates
over all glyphs. The more optimized implementation for CoreText
uses the native API.

Change-Id: I9c5b8115f72fb9ade3892a65ddbed76f7af0a580
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-11-27 17:34:29 +01:00
Volker Hilsheimer
4502025dcd QFontEngine: add API to get the name of a glyph
Some fonts name their glyphs in the "post" or "cff" tables, and both
CoreText and FreeType provide high-level APIs to access those values.
Also, harfbuzz has an API for OpenType fonts, which we can use on
Windows (where we would have to load the font into FreeType, as
neither GDI nor DirectWrite provide APIs to access this data), and as
default implementation that we can fall back to if the platform APIs
don't find anything.

We need to set the harfbuzz font up with the OpenType callbacks
explicitly, so cannot just use what we get from harfbuzzFont.

With this low-level API we can now make name-based lookups of glyphs,
and eventually render those in a QIconEngine implementation.

Task-number: QTBUG-102346
Change-Id: I68cc19814fc45d63a88e063b719b46f6aa6100bc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-11-27 11:41:42 +01:00
Volker Hilsheimer
4db368d474 QFontEngine: add test coverage and benchmark for all engines
For some known fonts, confirm that we get the right glyph count and
glyph index for specific unicode code points.

Create QGuiApplication with a specific font engine, and test the fonts
with all engines. On Windows, that's DirectWrite, GDI, and Freetype;
on macOS CoreText and Freetype; and otherwise only Freetype.

Not all fonts will be available with all engines, so test in each test
function whether the font is a good enough match (family is enough, no
need to do a deep test).

Add a benchmark as well, using the same setup plumbing, but with
different test functions.

Change-Id: I2ed279965fc3f1dc3f283d0fe7b018fc3035c67d
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-11-27 11:41:42 +01:00
Lucie Gérard
4c83657448 Add REUSE.toml files
Those files are read by reuse to complement or override the copyright
and licensing information found in file.

The use of REUSE.toml files was introduced in REUSE version 3.1.0a1.
This reuse version is compatible with reuse specification
version 3.2 [1].
With this commit's files,
* The SPDX document generated by reuse spdx conforms to SPDX 2.3,
* The reuse lint command reports that the Qt project is reuse compliant.

[1]: https://reuse.software/spec-3.2/

Task-number: QTBUG-124453
Task-number: QTBUG-125211
Pick-to: 6.8
Change-Id: I01023e862607777a5e710669ccd28bbf56091097
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-11-05 14:36:16 +01:00
Mårten Nordheim
b2e0ff4bca tst_bench_qobject: Fix stdAllocator case for Windows
The total stack space available is 1MB, but each pointer is 8 bytes.
So we have to limit the amount of pointers we allocate on the stack to
somewhere below 128K.

Pick-to: 6.8 6.7 6.5
Change-Id: I1d1262a4048cf4b3fed8df813decc3e142430a32
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-10-25 20:51:58 +00:00
Tor Arne Vestbø
3d08816f4c Darwin: Teach QFileSystemEngine how to resolve case-sensitivity
Both APFS and HFS+ can be both case-sensitive and case-insensitive
(the default), and the mounted file system may be any other file
system than these two as well, so hard-coding to case-sensitive
is not sufficient.

Pick-to: 6.8
Task-number: QTBUG-28246
Task-number: QTBUG-31103
Change-Id: Ibdb902df3f169b016a519f67ad5a79e6afb6aae3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-10-02 11:41:14 +00:00
Tatiana Borisova
fc5015877f tst_bench_qtimezone: fix a 'sign-compare' warning
- The problem is found by a clang-tidy tool.
Use size_t instead of qsizetype as a type for the index variable to
get rid of the warning.

The clang-tidy output:
tst_bench_qtimezone.cpp:130:30: warning: comparison of integer expressions of different signedness: ‘qsizetype’ {aka ‘long long int’}
and ‘std::size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
locIndex < std::size(locName) ? locName[locIndex] :
where.bcp47Name().toUtf8();

Task-number: QTBUG-105464
Change-Id: I603cbf201827e6e502c9737b02928f31ad6b2517
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-09-16 16:57:50 +00:00
Milian Wolff
e95fb04202 QSharedPointer: optimize casts on rvalue shared pointers
When we are casting an rvalue QSharedPointer, we do not need to
pay the cost for the atomic refcount increment / decrement. Optimize
this by adding rvalue overloads that handle this specific case
directly.

Note that this is arguably a micro optimization since in most cases
the cost to create the pointer in the first place is going to dwarf
the cost for the atomic increment / decrement. But it starts to matter
for situations like `someConstObject.ptrGetter().dynamicCast()` - in
the common case the `ptrGetter()` returns by value and the cast can
then operate on an rvalue.

On my system, the benchmark speaks for itself:

```
./tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr -perf -perfcounter cycles,instructions -iterations 100000 objectCast objectCast_rvalue
********* Start testing of tst_QSharedPointer *********
Config: Using QtTest library 6.9.0, Qt 6.9.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20240805), arch unknown
PASS   : tst_QSharedPointer::initTestCase()
PASS   : tst_QSharedPointer::objectCast()
RESULT : tst_QSharedPointer::objectCast():
     147.05521 CPU cycles per iteration (total: 14,705,522, iterations: 100000)
     147.00058 instructions per iteration, 1.000 instr/cycle (total: 14,700,058, iterations: 100000)
PASS   : tst_QSharedPointer::objectCast_rvalue()
RESULT : tst_QSharedPointer::objectCast_rvalue():
     52.00227 CPU cycles per iteration (total: 5,200,227, iterations: 100000)
     110.00056 instructions per iteration, 2.115 instr/cycle (total: 11,000,057, iterations: 100000)
PASS   : tst_QSharedPointer::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 45ms
********* Finished testing of tst_QSharedPointer *********

./tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr -perf -perfcounter cycles,instructions -iterations 100000 dynamicCast dynamicCast_rvalue
********* Start testing of tst_QSharedPointer *********
Config: Using QtTest library 6.9.0, Qt 6.9.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20240802), arch unknown
PASS   : tst_QSharedPointer::initTestCase()
PASS   : tst_QSharedPointer::dynamicCast()
RESULT : tst_QSharedPointer::dynamicCast():
     148.34457 CPU cycles per iteration (total: 14,834,457, iterations: 100000)
     120.00057 instructions per iteration, 0.809 instr/cycle (total: 12,000,058, iterations: 100000)
PASS   : tst_QSharedPointer::dynamicCast_rvalue()
RESULT : tst_QSharedPointer::dynamicCast_rvalue():
     25.00210 CPU cycles per iteration (total: 2,500,211, iterations: 100000)
     81.00057 instructions per iteration, 3.240 instr/cycle (total: 8,100,058, iterations: 100000)
PASS   : tst_QSharedPointer::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 45ms
********* Finished testing of tst_QSharedPointer *********

./tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr -perf -perfcounter cycles,instructions -iterations 100000 staticCast staticCast_rvalue
********* Start testing of tst_QSharedPointer *********
Config: Using QtTest library 6.9.0, Qt 6.9.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20240802), arch unknown
PASS   : tst_QSharedPointer::initTestCase()
PASS   : tst_QSharedPointer::staticCast()
RESULT : tst_QSharedPointer::staticCast():
     142.95894 CPU cycles per iteration (total: 14,295,894, iterations: 100000)
     54.00057 instructions per iteration, 0.378 instr/cycle (total: 5,400,058, iterations: 100000)
PASS   : tst_QSharedPointer::staticCast_rvalue()
RESULT : tst_QSharedPointer::staticCast_rvalue():
     14.00205 CPU cycles per iteration (total: 1,400,205, iterations: 100000)
     22.00056 instructions per iteration, 1.571 instr/cycle (total: 2,200,057, iterations: 100000)
PASS   : tst_QSharedPointer::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 50ms
********* Finished testing of tst_QSharedPointer *********

./tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr -perf -perfcounter cycles,instructions -iterations 100000 constCast constCast_rvalue
********* Start testing of tst_QSharedPointer *********
Config: Using QtTest library 6.9.0, Qt 6.9.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20240802), arch unknown
PASS   : tst_QSharedPointer::initTestCase()
PASS   : tst_QSharedPointer::constCast()
RESULT : tst_QSharedPointer::constCast():
     142.38115 CPU cycles per iteration (total: 14,238,116, iterations: 100000)
     54.00057 instructions per iteration, 0.379 instr/cycle (total: 5,400,058, iterations: 100000)
PASS   : tst_QSharedPointer::constCast_rvalue()
RESULT : tst_QSharedPointer::constCast_rvalue():
     13.00243 CPU cycles per iteration (total: 1,300,243, iterations: 100000)
     22.00057 instructions per iteration, 1.692 instr/cycle (total: 2,200,058, iterations: 100000)
PASS   : tst_QSharedPointer::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 42ms
********* Finished testing of tst_QSharedPointer *********
```

[ChangeLog][QtCore][QSharedPointer] Optimized casts on rvalue shared
pointers.

Change-Id: I7dfb4d92253d6c60286d3903bc7aef66acab5689
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-09-05 12:44:46 +02:00
Tian Shilin
063dad967f fix: Redundant condition in abstractitemcontainer
The check to see if m_itemView is empty is already
included in the first condition, and the re-check in
the second condition is unnecessary.
eg: A | | (!A && B) is equivalent to A | | B.

Pick-to: 6.8
Change-Id: I1a9f003bacea076fc1e72765c196a327a21c33b2
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-08-28 08:28:23 +08:00
Mårten Nordheim
ccbf2cd43c Speed up setup for QSet unite benchmark
Pick-to: 6.8 6.7 6.5
Change-Id: I38a56ae2c9f3dcbcb851cf63ae692cd7f9497989
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-08-27 07:37:33 +00:00
Edward Welbourne
01acb888e0 Add QTZ::displayName() benchmarks
Task-number: QTBUG-115158
Pick-to: 6.8 6.7 6.5 6.2 5.15
Change-Id: I7465a19f6003cfae7507d798fadeab22bf1b118d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-08-16 15:42:13 +02:00
Edward Welbourne
45ec096672 Correct Arabic exponent separator in QLocale benchmarks
The separator was changed at CLDR v44 to use a plain aleph, U+0623,
rather than the U+0627 aleph with hamza above previously used. This
is, in both cases, followed by U+0633, "seen".

Task-number: QTBUG-121325
Task-number: QTBUG-126060
Pick-to: 6.8 6.7 6.5
Change-Id: I013525e0876c4c47111846135c9311e7b3442dd3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-08-16 15:42:13 +02:00
Edward Welbourne
9dab0aecc0 tst_QLocale: remove duplicate fromScriptLand_data() data rows
Pick-to: 6.8 6.7 6.5 6.2
Change-Id: I78ceb053d73fcf22deff7258a349a8ec22e7ad3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-08-16 15:42:13 +02:00
Ahmad Samir
e583c3d516 QDirListing: add flags to handle entries filtering
By extending IteratorFlag so that it replaces both QDir::Filter and
QDirIterator::IteratorFlag enums, but with better defaults (based on how
QDir/Iterator is used in 15-20 years worth of code in Qt and KDE).

Make the QDirListing(QDir ~~) ctor private, also change it to use
QDirIterator::IteratatorFlags; it will be used to port existing code.

If QDir is ported to use QDirListing::IteratorFlags, instead of
QDir::Filters, a public QDirListing(QDir) constructor can then be added.

Pick-to: 6.8
Fixes: QTBUG-125504
Task-number: QTBUG-125859
Change-Id: Ide4ff8279f554029ac30d0579b0e8373ed4337f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-06-27 03:35:02 +03:00
Lucie Gérard
0f7a64a3ad Add copyright and licensing to build system files missing it
Task-number: QTBUG-124453
Change-Id: Ibb6a0ab839a16ceef3c68861bac2f508ddb3d1ae
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-21 17:23:21 +02:00
Mårten Nordheim
6f2ef2eacb QDecompressHelper: update the benchmark
After the zip bomb checks were added the benchmark was not
adjusted.

Also move the QByteArray creation outside the loop, to not include
the time it takes to make a heap allocation.

Pick-to: 6.7 6.5
Change-Id: Ia958d497dd27fc61e0084b6f5c11d76886bb24c4
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-14 12:33:21 +00:00
Jari Helaakoski
0ae44ccc6f Improve test compilation setup with QtLite configuration
Functional fix will come later via separate tasks.

Task-number: QTBUG-122999
Change-Id: Ib805740c87ff21cea5a186add71cc594ab4d4df1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-10 09:04:44 +00:00
Jari Helaakoski
30cc8a28de Fix test compilation issues with QtLite configuration
Now developer build tests compile, but some are not working.
Functional fix will come later via separate tasks.

Task-number: QTBUG-122999
Change-Id: I70487b46c1b32ba4279cb02a4978e4f55ac0d310
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-06 14:29:02 +00:00
Edward Welbourne
4467ebc837 Add benchmarks for QDate::fromString()
These reveal a roughly factor of six slow-down for two valid date
formats and a roughly factor of twelve slow-down for an invalid one.

Pick-to: 6.7 6.5 6.2
Task-number: QTBUG-124465
Change-Id: Ibd21e43d4c64aced33ba5b21e4602e0dc4fd7548
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-04-22 18:56:21 +02:00
Eirik Aavitsland
b05ea7279e Add QPainter benchmark case re clipping primitives exceeding device
Task-number: QTBUG-123054
Change-Id: I7f3af505245817ea7030ff29d6244e4d5ce78e6c
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
2024-04-18 10:46:08 +02:00
Ahmad Samir
2a7c71bef0 tst_bench_qdiriterator: fix build on VxWorks
By removing fs::directory_options::skip_permission_denied which isn't
available on VxWorks.

It's not strictly needed for the benchmark. I had added it to test
locally by listing some dirs under '/' (not all of them are readable for
users), and saw no reason at the time to remove it. The benchmark itself
listing dirs in the qtbase source dir tree.

Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I4e68d01abd707dbf553f0a5832739ef0f4c9d585
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-13 23:37:35 +02:00
Thiago Macieira
55959aefab qHash: implement an AES hasher for QLatin1StringView
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>
2024-03-12 18:23:09 -07:00
Ahmad Samir
5e9de279ac tst_bench_qdiriterator: add benchmark for QDirListing
Make the benchmarks more comparable:
- Store the QDir::Filters in one central var, this way it's the same in
  all the call sites

- Add a `bool forceStat`, when true force calling stat(), either
  explicitly in posix_helper(), or implicitly in Qt classes by e.g.
  calling a QFileInfo method that would have to call system stat()
  internally. Otherwise benchmarking readdir()/dirent showed bigger
  times, which was mostly due to the explicit stat() calls, whereas we
  can use dirent::d_type (on the platforms where it's available)

Drive by change: for std::filesystem::recursive_directory_iterator, set
skip_permission_denied option and use the non-throwing constructor.

Change-Id: Icf138a5dc41d32741c1be611d664b01008b2f3fe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-29 16:35:57 +02:00
Juha Vuolle
3e2a811f7a Add benchmark test for QHttpHeaders
Fixes: QTBUG-122472
Change-Id: I8293bb49926ea63a4456e6c3affe1853be9ab86b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-02-29 13:53:25 +02:00
Lucie Gérard
ff1039c217 Change license for tests files
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>
2024-02-04 09:56:42 +01:00
Mårten Nordheim
000cb2dadc Bench QSet::unite
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>
2024-02-01 00:43:23 +01:00
Marcin Zdunek
1d4ab5c135 Remove qfunctions_vxworks files and usage as it is no longer needed
Task-number: QTBUG-115777
Change-Id: I0d803ac7ce067737b79a39a267a2b0eb509ae0b8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-01-25 12:21:41 +01:00
Mårten Nordheim
aec39bd136 tst_bench_{qhash,qset}: set deterministic seed
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>
2024-01-23 05:17:06 +01:00
Marc Mutz
a5bcb41678 tst_bench_QImageReader: add a benchmark for raw QFatoryLoader operations
This is Eirik's QtCore-only QTBUG-114253 reproducer added to the
nearest fitting existing benchmark.

Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io>
Pick-to: 6.6 6.5 6.2 5.15
Task-number: QTBUG-114253
Change-Id: Iba68bedebae908af497267860e2b230db269787e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-12-07 22:55:08 +00:00