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

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

XMLWordPrintable

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

      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

       

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

            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

              Created:
              Updated:

                There are no open Gerrit changes