AbstractTreeViewer.add method performance. [message #453249] |
Sat, 02 April 2005 00:03  |
Eclipse User |
|
|
|
When implementing deferred loading for the TreeViewer I stumbled upon serious performance problems in the
AbstractTreeViewer.add(Object parentElement, Object[] childElements) method.
The amount of time this method takes grows exponentially with the size of the childElements array.
After profiling it turns out that the problem is that the method is not optimized for loading multiple elements. It essentially adds each element separately.
The main problem is that getItems(Item) method is called several times for each element in the childElements array.
This method sends message to native Windows control to get children for a given item. The time it takes for getItems to execute grows exponentially with the each item added.
We do not have control over the performance of the native widgets but we can optimize calls to them.
I created OptimizedTreeViewer class that overrides the internalAdd method and uses a single call to getItems to load all the children.
The difference in performance is huge. To add 5000 items in the original tree is ~10 sec with my implementation it takes less then 1 sec.
The optimized class is attached.
Comments are appreciated.
Thanks.
Dimitry Fayerman
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.23976 seconds