Dear all,
I've a very big wxGrid, around 50 columns and more than 2000 rows, don't ask me why that many columns, clients are crazy, right? And I also have a functionality to show/hide columns, but still there are tenth of shown columns and, in general, all could be shown together. So I was debugging the thing and found that it was spending oh so much time in a loop to auto size all the columns, becouse I've seen that wxGrid::AutoSizeColumn calls wxGridCellAttrProvider::GetAttr for every and any cell of the column. Is this a known issue?
I'm using wxGrid base class, without deriving my own wxGridTableBase, so I'd like to ask to you whether you do think it would be worth to try to do that and also set my own wxGridCellAttrProvider in it and if you know any good example for that thing.
Thank you, BR,
Max.
wxGrid::AutoSizeColumn kills my performances
Re: wxGrid::AutoSizeColumn kills my performances
How else should it do it? It has to iterate over all cells to calculate the minimum size.So I was debugging the thing and found that it was spending oh so much time in a loop to auto size all the columns, becouse I've seen that wxGrid::AutoSizeColumn calls wxGridCellAttrProvider::GetAttr for every and any cell of the column. Is this a known issue?
I don't think this will help.I'm using wxGrid base class, without deriving my own wxGridTableBase, so I'd like to ask to you whether you do think it would be worth to try to do that and also set my own wxGridCellAttrProvider in it and if you know any good example for that thing.
I think it's better to not use wxGRID_AUTOSIZE and call wxGrid::AutoSize() manually whenever it's useful, e.g. whenever data changed or rows were added/deleted.
Use the source, Luke!
Re: wxGrid::AutoSizeColumn kills my performances
I was asking whether the known issue was such a slowness in getting the attributes. Is wxGrid::AutoSizeColumn already optimized? And what if I'd override wxGrid::AutoSizeColumn and use an efficient algorithm to find out the longest string, do you think I would improve its performances?doublemax wrote:How else should it do it? It has to iterate over all cells to calculate the minimum size.So I was debugging the thing and found that it was spending oh so much time in a loop to auto size all the columns, becouse I've seen that wxGrid::AutoSizeColumn calls wxGridCellAttrProvider::GetAttr for every and any cell of the column. Is this a known issue?
I'm not using wxGRID_AUTOSIZE already.doublemax wrote:[I don't think this will help.I'm using wxGrid base class, without deriving my own wxGridTableBase, so I'd like to ask to you whether you do think it would be worth to try to do that and also set my own wxGridCellAttrProvider in it and if you know any good example for that thing.
I think it's better to not use wxGRID_AUTOSIZE and call wxGrid::AutoSize() manually whenever it's useful, e.g. whenever data changed or rows were added/deleted.
Re: wxGrid::AutoSizeColumn kills my performances
My guess would be that the most time is spent in wxGridCellStringRenderer::DoGetBestSize(), especially the call to wxDC::GetTextExtent(). There is definitely room for optimization there or at a higher level.I was asking whether the known issue was such a slowness in getting the attributes. Is wxGrid::AutoSizeColumn already optimized? And what if I'd override wxGrid::AutoSizeColumn and use an efficient algorithm to find out the longest string, do you think I would improve its performances?
Use the source, Luke!