Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-90560

QVariant performance regression in Qt6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.0.1
    • None
    • All

      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.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            fabiankosmale Fabian Kosmale
            vladimir.kraus Vladimir Kraus
            Votes:
            8 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes