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

QDateTime constructor performance regression when year is below epoch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P2: Important P2: Important
    • None
    • 6.3.0
    • Core: Date/Time
    • None
    • macOS, Windows
    • 21
    • 35d0f012e (dev), 0f4fb0bf2 (dev)
    • Foundation Sprint 87

      There seems to be a severe performance regression in how QDateTime handles dates with very low years (probably all years below epoch). This manifested in our application with severe stuttering.

      This code reproduces the problem quickly:

      QElapsedTimer timer;
      timer.start();
      for (qint64 i = 0; i < 1E7; i++)
          QDateTime someday(QDate(1, 1, 1), QTime(0, 0));
      qDebug() << "Elapsed:" << timer.elapsed();

      This code takes a huge amount of time, I didn't even reach the end. If you replace the year with a value > 1970, then the time to complete is reasonable.

      I can reproduce this in MacOS and Windows. I cannot reproduce in Linux.

      Qt 5.15 does not seem to be affected.

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

            Eddy Edward Welbourne
            luc4 Luca Carlon
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: