qt5base-lts/tests/benchmarks/corelib
Dennis Oberst 3c38efbfe4 QByteArray: use new assign() in operator=(const char *)
operator=(~) and assign(~) share similar names but, until now, have not
shared the same functionality. This patch introduces the usage of
QByteArray::assign() within the non-sharing assignment operator to
effectively boost efficiency by reusing the available capacity.

Since these assignment operators are frequently used in many places,
both within Qt and non-Qt code, this patch comes with benchmarks.

The preview of the benchmark results are compared with this patch and
before this patch. The findings indicate a slight enhancement in
performance associated with the assignment operator. Despite the results
displaying only a minor improvement, progress has been made. Therefore
use assign(QByteArrayView) as replacement.

(x86_64-little_endian-lp64 shared (dynamic) release build (O3); by
gcc 13.2.1, endeavouros ; 13th Gen Intel(R) Core(TM) i9-13900K

benchmarks executed with -perf -iterations 1000000

  * The last value at the EOL represent the string size.

QByteArray &operator=(const char *ch) (current)
  65    cycles/iter; 317  instructions/iter; 16.0 nsec/iter (5)
  71.7  cycles/iter; 383  instructions/iter; 13.0 nsec/iter (10)
  59.8  cycles/iter; 318  instructions/iter; 10.9 nsec/iter (20)
  70.8  cycles/iter; 340  instructions/iter; 12.9 nsec/iter (50)
  80.2  cycles/iter; 419  instructions/iter; 14.6 nsec/iter (100)
  164.2 cycles/iter; 899  instructions/iter; 29.9 nsec/iter (500)
  260.5 cycles/iter; 1522 instructions/iter; 45.6 nsec/iter (1'000)

QByteArray &operator=(const char *ch) (before)
  66.8  cycles/iter; 317  instructions/iter; 16.9 nsec/iter (5)
  76.5  cycles/iter; 383  instructions/iter; 13.9 nsec/iter (10)
  63.7  cycles/iter; 318  instructions/iter; 11.6 nsec/iter (20)
  71.6  cycles/iter; 344  instructions/iter; 13.0 nsec/iter (50)
  77.5  cycles/iter; 419  instructions/iter; 14.1 nsec/iter (100)
  143.4 cycles/iter; 893  instructions/iter; 26.1 nsec/iter (500)
  270.8 cycles/iter; 1516 instructions/iter; 48.2 nsec/iter (1'000)

Task-number: QTBUG-106201
Change-Id: I0745c33f0f61f1d844a60960cc55f565320d5945
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-11 14:11:44 +02:00
..
io tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
itemmodels QSortFilterProxyModel: port to PMF connects for performance reasons 2023-02-02 20:43:59 +01:00
json tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
kernel CMake: remove check for cxx11_future 2023-08-02 12:36:18 -07:00
mimetypes QMimeDatabase benchmark: measure only what it pertinent 2023-08-09 23:57:21 +02:00
plugin tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
text QByteArray: use new assign() in operator=(const char *) 2023-08-11 14:11:44 +02:00
thread Long live QtFuture::makeReadyVoidFuture() and QtFuture::makeReadyValueFuture() 2023-04-05 13:38:15 +02:00
time Simplify (and fix) initialization of a list of time-zones 2023-07-19 22:50:32 +02:00
tools tst_bench_QCryptographicHash: use resultView() 2023-03-31 10:32:45 +01:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00