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

Bad performance of QDateTime object creation in Qt 6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 6.8.2
    • Core: Date/Time
    • None
    • Linux/X11

    Description

      QDateTime constructor costs nearly 100 times of computation resource in Qt 6 than Qt 5

       

      #include <QCoreApplication>
      #include <QDateTime>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
            qint64 utc = QDateTime::currentDateTime().toMSecsSinceEpoch();
      
            for (int i = 0; i < 100000; ++i) {
                  QDateTime(
                     QDate(2025, 4, 27),
                     QTime(16, 29, 30, 999));
          }
          
            qint64 interval = QDateTime::currentDateTime().toMSecsSinceEpoch() - utc;
            qInfo("Interval is %lld", interval);
          return 0;
      } 

      The same code outputs: 'Interval is 73' in Qt 5.

      In Qt 6 it outputs: Interval is 7191.

      Tested on the same machine, with Ubuntu 24.04.2

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            yanzhikai Zhikai Yan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes