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

QDateTime constructor performance regression when year is below epoch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.3.0
    • Core: Date/Time
    • None
    • macOS, Windows
    • 21
    • Foundation PM Prioritized

    Description

      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.

      Attachments

        Activity

          People

            cnn Qt Core & Network
            luc4 Luca Carlon
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: