Open roland171281 opened 2 years ago
I spent some time profiling the hypertreelist and I think that there are several things which could be done more efficiency.
- if i remove the self.CalculateSize(item, dc)@4139 the opening time is reduced from about 20sec to 2secs
- I think he calculates the size of all element even if they are not drawn
- snakeviz shows, that the time is also spent in CalculateSize again
- and in this Function the time is mostly spent in GetFullMultiLineTextExtent
- here hypertreelist.py:2850(PaintItem) is dominant
Hope this helps a little bit. I think there is some optimizaion potential like not always asking the sizes and set pens ... But it's also clear to me that this is risky & will cost much time to optimize. BR Roland
If you have a moment can you test out the pull request to see if it fixes your slowdown issues?
Hi,
I tested your request and there is a huge speedup -> great work! Filling the table seems to as fast as the old gizmos version.
The only things I mentioned is:
BUT it also seems to be more reliable than the 2.8 gizmos.TreeListCtrl -> there is no "wrong drawing". So I can of course live with that.
Thank you very much!
BR Roland
What I found out is, that if I remove TR_HIDE_ROOT scrolling is much faster. And TR_VIRTUAL seems to be defective -> but maybe I'm just doing something wrong.
Can you post a program sample where the tree is still slow?
I don't think TR_VIRTUAL ever worked with HyperTreeList. The code looks broken even from 2010. If you have an example of a virtual tree that worked with the 2.8 gizmos.TreeListCtrl that would be very useful to help figure out how it should work.
Operating system: LIN64 / WIN64 wxPython version & source: 2.8 / 4.1.1 Python version & source: 2.7 / 3.8
Description of the problem:
The new version of the TreeListCtrl (only a compatibility wrapper based on hypertreelist) is much slower, if it gets big (1000 entries +). With slow I mean it takes long to be filled and is very laggy at scrolling, opening subchilds, ...
I tested the hypertreelist in wxpython2.8 and it's the same behavior. Only the TreeListCtrl is fast at 2.8
Please see example below. You can switch between hypertreelist / treelistctrl in the main It runs with 2.8 / 4.1.1
Thank you for your work and best regards Roland
Code Example (click to expand)
```python import wx import wx.lib.agw.hypertreelist as hypertreelist import wx.gizmos as gizmos import random class MyFrame(wx.Frame): def __init__(self, tree_type): wx.Frame.__init__(self, None, wx.ID_ANY) if wx.version().startswith("4"): if tree_type.startswith("hyper"): tree = hypertreelist.HyperTreeList(self, -1, style=0, agwStyle=hypertreelist.TR_DEFAULT_STYLE | hypertreelist.TR_HIDE_ROOT | hypertreelist.TR_FULL_ROW_HIGHLIGHT | hypertreelist.TR_ROW_LINES | hypertreelist.TR_COLUMN_LINES) else: tree = gizmos.TreeListCtrl(self, -1, style=0, agwStyle=gizmos.TR_DEFAULT_STYLE | gizmos.TR_HIDE_ROOT | gizmos.TR_FULL_ROW_HIGHLIGHT | gizmos.TR_ROW_LINES | gizmos.TR_COLUMN_LINES) else: if tree_type.startswith("hyper"): tree = hypertreelist.HyperTreeList(self, -1, style=0, agwStyle=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_ROW_LINES | wx.TR_HAS_VARIABLE_ROW_HEIGHT | wx.TR_NO_LINES | wx.TR_COLUMN_LINES) else: tree = gizmos.TreeListCtrl(self, -1, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_ROW_LINES | wx.TR_COLUMN_LINES) col_count = 10 for i in range(col_count): tree.AddColumn("Column "+str(i)) tree.SetMainColumn(0) root = tree.AddRoot("The root item") for i in range(2): child = tree.AppendItem(root, "platform "+str(i)) for i in range(5000): child_child = tree.AppendItem(child, "job "+str(i)) for col in range(col_count): tree.SetItemText(child_child, str(random.randrange(10)), col+1) for i in range(2): tree.AppendItem(child_child, "diff "+str(i)) if __name__ == '__main__': app = wx.App(False) #mainwin = MyFrame("hyper") mainwin = MyFrame("gizmos") mainwin.Show(True) mainwin.SetSize((1100, 800)) app.MainLoop() ```