[PyQt] Observations with nesting-level: Performance of QTreeView
Baz Walter
bazwal at ftml.net
Sun Oct 10 17:39:19 BST 2010
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 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 :)
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?
here are my results:
[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}
More information about the PyQt
mailing list