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

Repeatedly calling QLocale::toString with timezone is slower than it should be

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7
    • Core: Date/Time
    • None
    • Fedora 39, KDE Plasma
    • Linux/Wayland, Linux/X11

    Description

      When profiling Neochat I found that calling

      new Date().toLocaleString(Qt.locale(), Locale.LongFormat) 

      repeatedly contributes a non-negligible amount of cycles to the runtime.

       

      This is because for each invocation the timezone data is recreated, despite it always being the same. It might be worth caching the timezone name lookup somehow.

      Attached is a Flamegraph for

       

      for (int i=0; i<1000; i++) {
          QDateTime time = QDateTime::currentDateTime();
          qWarning() << QLocale().toString(time, QLocale::LongFormat);
      } 

      Tested with current 6.7 branch

       

      Attachments

        Issue Links

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

          Activity

            People

              Eddy Edward Welbourne
              nicolasfella Nicolas Fella
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes