Bug 186268 - Virtual table : tableItem.setText slows down near bottom of table
Summary: Virtual table : tableItem.setText slows down near bottom of table
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2007-05-09 17:53 EDT by Kwong Lai CLA
Modified: 2016-08-05 13:49 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kwong Lai CLA 2007-05-09 17:53:54 EDT
Build ID: M20070212-1330

Steps To Reproduce:

I'm noticing significant delays when scrolling near the bottom of my virtual table (8 columns, 50000 rows).

   After some investigation, I've found the delay is caused by calls to setText() in the event handler.

   Using Snippet 144 as a guide (1000000 rows in the table), setText took the following times for these rows:

        row 1      took 0ms
        row 50000  took 2ms
        row 100000 took 3ms
        row 500000 took 16ms
        row 999998 took 39ms

   So the lower down the table I scroll, the longer it takes to setText for each row. 

   This happens regardless of whether I scroll through every row to get to the bottom, or just drag the scroll bar all the way down (without triggering events to the rows in the middle).

   I'm using version 3.2.2.v3236 of the org.eclipse.swt.gtk.linux.x86 plug-in, in case this information helps. I've also included the snippet I used to do the timing at the bottom. 


More information:
-----------------------------------------------

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;

public class Snippet144 {

    static final int COUNT = 1000000;

    public static void main(String[] args) {
        Display display = new Display ();
        final Shell shell = new Shell (display);
        shell.setLayout (new RowLayout (SWT.VERTICAL));
        final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);

        table.addListener (SWT.SetData, new Listener () {
            public void handleEvent (Event event) {
                TableItem item = (TableItem) event.item;
                int index = table.indexOf (item);
                long startTime = System.currentTimeMillis();
                item.setText ("Item " + index);
                long timeTaken = System.currentTimeMillis() - startTime;
                System.out.println ("row " + index + " took " + timeTaken +
"ms");
            }
        });
        table.setLayoutData (new RowData (200, 200));
        Button button = new Button (shell, SWT.PUSH);
        button.setText ("Add Items");
        final Label label = new Label(shell, SWT.NONE);
        button.addListener (SWT.Selection, new Listener () {
            public void handleEvent (Event event) {
                long t1 = System.currentTimeMillis ();
                table.setItemCount (COUNT);
                long t2 = System.currentTimeMillis ();
                label.setText ("Items: " + COUNT + ", Time: " + (t2 - t1) +
" (ms)");
                shell.layout ();
            }
        });
        shell.pack ();
        shell.open ();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
    }
}
Comment 1 Grant Gayed CLA 2007-05-10 10:39:12 EDT
happens in 3.3 as well
Comment 2 Silenio Quarti CLA 2007-05-16 11:08:58 EDT
I was not able to reproduce this on my machine. Could you provide the version of GTK you are running? Grant, add yours as well. Thanks!

Comment 3 Grant Gayed CLA 2007-05-16 11:25:51 EDT
I'm on gtk 2.4.13 (RHEL4).
Comment 4 Kwong Lai CLA 2007-05-16 17:31:46 EDT
Mine is 2.4.9-10 on Suse 9.2
Comment 5 Eric Williams CLA 2016-08-05 13:49:12 EDT
The output of the snippet produces the following on my system:
row 0 took 1ms
row 1 took 0ms
row 2 took 0ms
row 3 took 1ms
row 4 took 0ms
row 5 took 0ms
row 6 took 0ms
row 7 took 0ms
row 262143 took 0ms
row 8 took 0ms

for GTK3, for GTK2:
row 0 took 0ms
row 1 took 1ms
row 2 took 0ms
row 3 took 0ms
row 4 took 0ms
row 5 took 0ms
row 6 took 0ms
row 7 took 0ms
row 8 took 0ms
row 262143 took 0ms

Overall time for GTK3 is 10.5 seconds, GTK2 is 7.8 seconds.

I'm going to close this bug, please feel free to re-open if the issue persists.