[PyQt] Observations with nesting-level: Performance of QTreeView

Knacktus knacktus at googlemail.com
Sun Oct 10 18:39:02 BST 2010


Am 10.10.2010 18:39, schrieb Baz Walter:
> On 10/10/10 15:43, Knacktus wrote:
>> Hi everyone,
>>
>> a little update of my observations so far for the interested:
>>
>> The flatter the tree, the better the performance. I've done some tests
>> with 10 children per parent. Now, that looks much better. For 100000
>> items expanding all takes about 30 seconds.
>
> is that a more realistic test of your actual use case?
I'm expecting on average 5 children per parent. Fortunately the 
performance is highly depending on the nesting.
>
> i'm not sure what to make of the example code you posted. given how
> expensive python method calls are, it doesn't seem all that surprising
> that you get relatively poor performance with *five thousand* levels of
> nesting :)
Well, if you know how Qt works, it might be natural. But if you don't 
(like me ;-)), you're surprised. I still wonder why the nesting levels 
make such a big difference.
>
> anyway, i profiled the expandAll() method in your example code (with
> max_items=5000). most methods get called 1-3 times per child item, which
> doesn't look abnormal. however it does look very different from the
> profiling results you posted earlier. are we testing the same thing?
>
I think so. To be sure I've attached a module with the code and the 
profiling commands. Note: I've added some code to allow variation of the 
number of children per parent.
> here are my results:
Those results are very interesting! Thanks.
Just to confirm: You had 5000 items and to expand the whole tree took 
only 0.67 seconds? Also, only 1 call to parent().
Now, that makes my wonder and hope. The main differences are that I'm on 
Windows 7 and I'm using pyqt 4.7.4 (build on Qt 4.6 afaik). I've read 
about some performance optimisation in Qt 4.7. That would be great news.
>
> [arch-linux 2.6.35, python 2.7, qt 4.7.0, sip 4.11.1, pyqt 4.7.7]
>
> 110103 function calls in 0.670 CPU seconds
>
> ncalls tottime percall cumtime percall filename:lineno(function)
> 1 0.000 0.000 0.670 0.670 <string>:1(<module>)
> 10003 0.095 0.000 0.317 0.000 tree_model.py:178(rowCount)
> 5001 0.022 0.000 0.031 0.000 tree_model.py:190(columnCount)
> 24 0.000 0.000 0.000 0.000 tree_model.py:193(data)
> 12 0.000 0.000 0.000 0.000 tree_model.py:206(headerData)
> 5005 0.046 0.000 0.128 0.000 tree_model.py:213(index)
> 1 0.000 0.000 0.000 0.000 tree_model.py:218(parent)
> 15012 0.093 0.000 0.154 0.000 tree_model.py:233(
> view_item_from_index)
> 4999 0.021 0.000 0.021 0.000 tree_model.py:43(__init__)
> 15008 0.060 0.000 0.110 0.000 tree_model.py:50(children)
> 5000 0.029 0.000 0.050 0.000 tree_model.py:77(
> get_view_item_children)
> 3 0.000 0.000 0.000 0.000 {built-in method column}
> 5005 0.021 0.000 0.021 0.000 {built-in method createIndex}
> 1 0.194 0.194 0.670 0.670 {built-in method expandAll}
> 15005 0.029 0.000 0.029 0.000 {built-in method
> internalPointer}
> 15012 0.033 0.000 0.033 0.000 {built-in method isValid}
> 3 0.000 0.000 0.000 0.000 {getattr}
> 15007 0.028 0.000 0.028 0.000 {len}
> 1 0.000 0.000 0.000 0.000 {method 'disable' of
> '_lsprof.Profiler' objects}
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: QTreeView_Performance.py
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101010/17fcf413/attachment.ksh>


More information about the PyQt mailing list