Community
Participate
Working Groups
Created attachment 84102 [details] Example program to demonstrate sort speeds Build ID: M20070212-1330 Steps To Reproduce: 1.Compile and run the attached program. 2.Clicking on Column 1 will print out the time to perform the sorting of the data and also the time to complete the table sort. 3.Clicking on Column 2 will print out the time to refresh the table. More information: In order to get the time for the data sort I override the sort method on MyViewerSorter and time the call to super.sort(). I added timing for refresh as after looking into the source code I noticed installing a new sorter invokes the refresh() method. As can be seen for a 10,000 row table refresh times are less then 0.02 seconds, the time to sort the actual data is also less then 0.02 seconds, however the total time to sort and refresh the table is often over 3 seconds. My guess is the time is taken re-indexing the rows.
Have you tried this: tableViewer.getTable().setRedraw(false); try { tableViewer.refresh(); } finally { tableViewer.getTable().setRedraw(true); }
Your suggestion makes a big difference - total time to sort the table is now down to under .1 seconds (compared to over 3 seconds). However, everywhere I change the table sorter my code now looks like: _viewer.getTable().setRedraw(false); try { _viewer.setSorter(new MyViewerSorter(up)); _viewer.refresh(); } finally { _viewer.getTable().setRedraw(true); } Which is OK - however would it not be possible to enable and disable the redraw within the TableViewer.setSorter() method?
We don't like to call setRedraw() on behalf of clients because they guarantee flicker at the setRedraw(true) time. If you have very few items, there is no performance gain, and should you call many methods that turn off/on redraw after another, it would lead to a lot of flicker.
OK - but how does the average user know that they should disable redraw when they change the sorter for a large table? Could you not add another setSorter method which takes a boolean which would disable the redraw - Adding this method would at least place something in the JavaDoc.
Hitesh is now responsible for watching bugs in the [Viewers] component area.
According to the Javadoc ViewerSorter has been replaced with ViewerComparator. Also given the age of this bug, it seems unlikely that this bug will get attention. Therefore I close this bug, as WONTFIX. If you see the same problem with ViewerComparator please open a new bug.