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,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView performances

    Have you tried gprof? It's faster than callgrind because it doesn't emulate the cpu and it's standard, so there are tools to use it. You can use it with GCC only, but I take it that's not a problem for you

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

    Default Re: QTableView performances

    Hi calmspeaker,

    I prepared for you a package containing:
    1-A class managing errors with history.
    2-A class managing indented traces with error and profiling.
    3-A document to explain how to use it.

    I hope it will help you.
    If you need help, contact me.

    I will test your proposal.
    Attached Files Attached Files

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

    Default Re: QTableView performances

    Hi,

    Here is the result of my test with layoutAboutToBeChanged + layoutChanged.

    Without this modification, I get:
    Qt Code:
    1. ##methode nb call millisecondes moyenne min max propre moyenne propre %
    2. ##SKGObjectModel::data 2705890 43950,9 0,02 0 60,99 31727,7 0,01 39,24%
    3. ##SKGObjectModelBase::data 2347017 12969,1 0,01 0 37,98 12309,6 0,01 15,23%
    4. ##SKGObjectModelBase::rowCount 2707786 10864,1 0 0 22,39 10864,1 0 13,44%
    5. ##SKGObjectModelBase::index 2707746 9032,57 0 0 27,68 9032,57 0 11,17%
    6. ##QAbstractItemModel::reset-fill 14 21129,6 1509,26 0,19 20674,1 8237,73 588,41 10,19%
    7. ##SKGObjectModelBase::headerData 251522 4541,63 0,02 0 16,52 3054,3 0,01 3,78%
    8. ##SKGServices::executeSelectSqliteOrder(QSqlDatabase) 174 2351,37 13,51 0,03 730,59 2351,37 13,51 2,91%
    9. ##SKGMainPanel::SKGMainPanel 1 4144,91 4144,91 4144,91 4144,91 820,56 820,56 1,01%
    To copy to clipboard, switch view to plain text mode 

    With the modification:
    Qt Code:
    1. ##methode nb call millisecondes moyenne min max propre moyenne propre %
    2. ##SKGObjectModel::data 1939034 31138,4 0,02 0 32,87 22583,8 0,01 37,16%
    3. ##SKGObjectModelBase::data 1667650 9058,82 0,01 0 27,76 8592,84 0,01 14,14%
    4. ##QAbstractItemModel::reset-fill 14 21189,3 1513,52 0,13 20886,5 8319,58 594,26 13,69%
    5. ##SKGObjectModelBase::rowCount 1941008 7398,6 0 0 35,16 7398,6 0 12,17%
    6. ##SKGObjectModelBase::index 1940968 6369,83 0 0 20,05 6369,83 0 10,48%
    7. ##SKGServices::executeSelectSqliteOrder(QSqlDatabase) 174 2528,14 14,53 0,03 759,23 2528,14 14,53 4,16%
    8. ##SKGObjectModelBase::headerData 170665 2962,19 0,02 0 12,09 1976,83 0,01 3,25%
    9. ##SKGServices::executeSqliteOrder(QSqlDatabase) 379 1612,22 4,25 0,03 533,94 831,15 2,19 1,37%
    10. ##SKGMainPanel::SKGMainPanel 1 3931,13 3931,13 3931,13 3931,13 715,1 715,1 1,18%
    To copy to clipboard, switch view to plain text mode 

    Conclusion:
    It's better because the number of call reduced.
    It's not enough.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.

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

    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.

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

    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

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.

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

    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 ?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.

  10. 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.