-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.0.1
-
None
I tried a simple benchmark of new QVariant in Qt6 and it shows significant slowdown (2 to 3 times) when compared to Qt5.
QElapsedTimer t; t.start(); int sum = 0; for (int i = 0; i < 100000000; ++i) { int a = 1; QVariant v = a; int b = v.toInt(); sum += b; } qDebug() << sum << t.elapsed();
On my environment (Windows 10, MSVC 2019, 64bit) the measured times are around 1.5 secs with Qt 6.0.1 and 0.6 secs with Qt 5.15.2. This is 2.5x slowdown.
I measured similar slowdowns with QString.
I know that these numbers quite insignificant per se and conversions are still fast in most real life situations, but this can mean that QVariant usage becomes a burden in some performance heavy scenarios. Natural example which comes to my mind is sorting of a large data model which require conversions to/from QVariant of each value.
But maybe there is potential for some type specialization for most prevalent types such asĀ int, double or QString which could regain some more performance.
- resulted in
-
QTBUG-90673 Speed up QVariant by using QMetaTypeInterface directly
-
- Closed
-
For Gerrit Dashboard: QTBUG-90560 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
331480,4 | QVariant: avoid superfluous QMetaType lookup | dev | qt/qtbase | Status: MERGED | +2 | 0 |
331489,5 | QVariant: Do not destroy trivial types | dev | qt/qtbase | Status: MERGED | +2 | 0 |