Results 1 to 19 of 19

Thread: QTableView performances

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTableView performances

    I really suggest to modify the implementation of data(). It is currently very inefficient and it's one of the most often called methods.

  2. #2
    Join Date
    Aug 2008
    Posts
    70
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: QTableView performances

    Quote Originally Posted by wysota View Post
    I really suggest to modify the implementation of data(). It is currently very inefficient and it's one of the most often called methods.
    I will try but it's not so easy !
    I will take you informed.

    In any case, thank you for your help.

  3. #3
    Join Date
    Aug 2008
    Posts
    70
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: QTableView performances

    Hi wysota,

    I have got 2 bad news:

    1-I optimized data method and after that, I commented in data methods all the code concerning decoration, tooltip, alignment, etc to keep only the text. Even with this, I win only 6% of performances. .
    Conclusion: even with perfect code in data, I won't have good performances.

    2-The solution based on layoutAboutToBeChanged + layoutChanged generates some regressions.
    (indexes seems to be not recomputed and so are still pointing on deleted internal data).

    I don't know what to do.

    PS1: I attached my new implementation.
    PS2: I don't know if it's very important, but I use a proxy (filter & sort) too.
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTableView performances

    The implementation is still very inefficient. You are still comparing strings instead of enums or numbers and you don't do any serious caching of calculated data.

    6% performance gain is already much, don't underestimate it.

  5. #5
    Join Date
    Aug 2008
    Posts
    70
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: QTableView performances

    Hi wysota,

    Today, I have got a good new.
    I understood why I have so bad performances.
    In fact, it's due to these lines:
    Qt Code:
    1. ui.kOperationView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    2. ui.kOperationView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    To copy to clipboard, switch view to plain text mode 

    If I comment these lines, I have got:
    Qt Code:
    1. ##methode , nb call , millisecondes , moyenne , min , max , propre , moyenne propre
    2. ##SKGServices::executeSelectSqliteOrder(QSqlDatabase) , 173 , 2250.3 , 13.0075 , 0.0319843 , 757.705 , 2250.3 , 13.0075
    3. ##SKGObjectModelBase::data , 77777 , 2022.72 , 0.0260067 , 0.00187886 , 17.3499 , 2011.33 , 0.0258602
    4. ##SKGObjectModelBase::refresh-reset , 13 , 4078.05 , 313.696 , 0.00701368 , 3962.67 , 1081.16 , 83.166
    5. ##SKGObjectModel::data , 71620 , 2738.77 , 0.0382403 , 0.00292969 , 17.3791 , 776.344 , 0.0108398
    6. ##SKGServices::executeSqliteOrder(QSqlDatabase) , 379 , 1319.9 , 3.48257 , 0.0279003 , 444.459 , 679.188 , 1.79205
    7. ##SKGMainPanel::SKGMainPanel , 1 , 2419.67 , 2419.67 , 2419.67 , 2419.67 , 372.141 , 372.141
    8. ##SKGObjectModelBase::index , 73266 , 295.21 , 0.00402929 , 0.00190628 , 10.6721 , 295.21 , 0.00402929
    9. ##SKGObjectModelBase::rowCount , 73305 , 223.636 , 0.00305076 , 0.00187886 , 11.12 , 223.636 , 0.00305076
    10. ##SKGObjectModelBase::clear , 17 , 201.88 , 11.8753 , 0.00792778 , 176.784 , 201.88 , 11.8753
    11. ##SKGObjectBase::getObjects , 62 , 1078.61 , 17.3969 , 0.0670469 , 932.943 , 184.245 , 2.9717
    12. ##SKGObjectModelBase::headerData , 9244 , 137.556 , 0.0148806 , 0.00188088 , 1.31897 , 104.604 , 0.0113158
    13. ##SKGSortFilterProxyModel::filterAcceptsRow , 4022 , 336.626 , 0.0836961 , 0.023957 , 0.784051 , 90.5983 , 0.0225257
    To copy to clipboard, switch view to plain text mode 

    As you can see, the number of calls is drastically reduced and performances are better (before 43s into data method, now 2s into data method ==> it's better than 6% ).

    Is it normal to have so bad performances when ResizeToContents is used ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTableView performances

    Yes, that's normal. sizeHint is queried all the time which in turns calls data() all the time, etc. I thought you knew that so I didn't even bother to mention it, sorry

    But honestly it's because of your hand-crafted profiler - it doesn't monitor methods which are called automatically by Qt or that are implemented by Qt, hence no references to sizeHint reading and hence my impression you weren't resizing columns to contents.

  7. The following user says thank you to wysota for this useful post:

    miraks (1st December 2008)

Similar Threads

  1. QTableView sorting
    By gabriels in forum Qt Programming
    Replies: 11
    Last Post: 6th October 2010, 17:13
  2. QTableView in ui with model/delegate
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 6th November 2008, 23:00
  3. QTableView
    By dragon in forum Qt Programming
    Replies: 0
    Last Post: 22nd September 2008, 16:53
  4. make QTableView work as a multi-column list view
    By wesley in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2008, 14:43
  5. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.