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

QFontMetricsF::horizontalAdvance() and QFontMetricsF::width() are much slow in Qt 5.15

    XMLWordPrintable

Details

    • Windows

    Description

      QFontMetricsF::horizontalAdvance() and QFontMetricsF::width() are much slow in Qt 5.15 comparing to Qt 5.6.
      Attached reproducer is an application that calls QFontMetricsF::horizontalAdvance() (for Qt 5.6, QFontMetricsF::width() instead) for each character in the target string ("This is the target string").

      When I run it with Qt 5.6, the total time was 21 ms, while it takes 385 ms with Qt 5.15. There is a difference larger than 10 times.
      I also tried letting Qt 5.15 use width(), and Qt 5.15 spent 422 ms even with width().
      This issue was reported by a commercial license user, and they are requireing a workaround improves the performance with Qt 5.15.

      <Qt 5.6.2, QFontMetricsF::width() >

      13:24:10: Starting C:\qt_projects\untitled63_QFontMetricsIssue\build\Desktop_Qt_5_6_2_MSVC2015_64bit-Debug\debug\untitled63_QFontMetricsIssue.exe...
      "Ariel,12,-1,5,50,0,0,0,0,0"
      01: 0054 19(ms) 9 1
      02: 0068 0(ms) 8 1
      03: 0069 0(ms) 4 1
      04: 0073 0(ms) 8 1
      05: 0020 0(ms) 4 1
      06: 0069 0(ms) 4 1
      07: 0073 0(ms) 8 1
      08: 0020 0(ms) 4 1
      09: 0074 0(ms) 4 1
      10: 0068 0(ms) 8 1
      11: 0065 0(ms) 9 1
      12: 0020 0(ms) 4 1
      13: 0074 0(ms) 4 1
      14: 0061 0(ms) 9 1
      15: 0072 0(ms) 5 1
      16: 0067 0(ms) 9 1
      17: 0065 0(ms) 9 1
      18: 0074 0(ms) 4 1
      19: 0020 0(ms) 4 1
      20: 0073 0(ms) 8 1
      21: 0074 0(ms) 4 1
      22: 0072 0(ms) 5 1
      23: 0069 0(ms) 4 1
      24: 006e 0(ms) 8 1
      25: 0067 0(ms) 9 1
      total time : 21 ms

       

      <Qt 5.15.18, QFontMetricsF::horizontalAdvance()>

      14:03:46: Starting C:\qt_projects\untitled63_QFontMetricsIssue\build\Desktop_Qt_5_15_18_MSVC2019_64bit-Debug\debug\untitled63_QFontMetricsIssue.exe...
      "Ariel,12,-1,5,50,0,0,0,0,0"
      01: 0054 384(ms) 9 1
      02: 0068 0(ms) 8 1
      03: 0069 0(ms) 4 1
      04: 0073 0(ms) 8 1
      05: 0020 0(ms) 4 1
      06: 0069 0(ms) 4 1
      07: 0073 0(ms) 8 1
      08: 0020 0(ms) 4 1
      09: 0074 0(ms) 4 1
      10: 0068 0(ms) 8 1
      11: 0065 0(ms) 9 1
      12: 0020 0(ms) 4 1
      13: 0074 0(ms) 4 1
      14: 0061 0(ms) 9 1
      15: 0072 0(ms) 5 1
      16: 0067 0(ms) 9 1
      17: 0065 0(ms) 9 1
      18: 0074 0(ms) 4 1
      19: 0020 0(ms) 4 1
      20: 0073 0(ms) 8 1
      21: 0074 0(ms) 4 1
      22: 0072 0(ms) 5 1
      23: 0069 0(ms) 4 1
      24: 006e 0(ms) 8 1
      25: 0067 0(ms) 9 1
      total time : 385 ms

       

      <Qt 5.15.18, QFontMetricsF::width() >

      14:03:03: Starting C:\qt_projects\untitled63_QFontMetricsIssue\build\Desktop_Qt_5_15_18_MSVC2019_64bit-Debug\debug\untitled63_QFontMetricsIssue.exe...
      "Ariel,12,-1,5,50,0,0,0,0,0"
      01: 0054 420(ms) 9 1
      02: 0068 0(ms) 8 1
      03: 0069 0(ms) 4 1
      04: 0073 0(ms) 8 1
      05: 0020 0(ms) 4 1
      06: 0069 0(ms) 4 1
      07: 0073 0(ms) 8 1
      08: 0020 0(ms) 4 1
      09: 0074 0(ms) 4 1
      10: 0068 0(ms) 8 1
      11: 0065 0(ms) 9 1
      12: 0020 0(ms) 4 1
      13: 0074 0(ms) 4 1
      14: 0061 0(ms) 9 1
      15: 0072 0(ms) 5 1
      16: 0067 0(ms) 9 1
      17: 0065 0(ms) 9 1
      18: 0074 0(ms) 4 1
      19: 0020 0(ms) 4 1
      20: 0073 0(ms) 8 1
      21: 0074 0(ms) 4 1
      22: 0072 0(ms) 5 1
      23: 0069 0(ms) 4 1
      24: 006e 0(ms) 8 1
      25: 0067 0(ms) 9 1
      total time : 422 ms

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            hitoshiito Hitoshi Ito
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes