Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Performance of setItemCount in SWT Tree
Performance of setItemCount in SWT Tree [message #479029] Sat, 08 August 2009 11:12 Go to next message
Eclipse User
Originally posted by: tom-public.shackell.org.uk

Hi,

I've been trying to create a virtual tree that can view very large
trees, with a large number of root items. However, I'm finding that
setItemCount is taking a very long time to execute, even if the items
aren't currently being viewed. This is on the WIN32 platform.

I've followed the approach described at:

http://www.eclipse.org/articles/Article-SWT-Virtual/Virtual- in-SWT.html

Here is the code I am using:

tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
tree.addListener(SWT.SetData, new Listener() {
@Override
public void handleEvent(Event event) {
TreeItem item = (TreeItem) event.item;
String name = "Item " + event.index;
item.setText(name);
}
});

long begin = System.currentTimeMillis();
tree.setItemCount(70000);
long end = System.currentTimeMillis();
System.out.println("Set item count took "+(end-begin)+" ms");

Typical times I am getting for running setItem count are upwards of 30
seconds, it seems that the even though the tree is virtual setItemCount
is creating all the items in one go.

Interestingly if I use a Table rather than a tree then there are no
performance issues at all. However, although this little snippet is
actually flat, in the actual final program the data will be a tree
(albeit a very long flat tree, with lots of roots).

So I was wondering whether anyone knew whether this is a known problem,
and whether there was any workaround to allow the use of large trees?


Thanks


Tom

------------------------------------------------------------ ------------
Cross posted from eclipse.platform.jface, after looking at it closely
this query isn't actually jface specific so I've reposted on the SWT list.
------------------------------------------------------------ ------------
Re: Performance of setItemCount in SWT Tree [message #479151 is a reply to message #479029] Sun, 09 August 2009 20:07 Go to previous messageGo to next message
Eclipse User
Originally posted by: vicenterg.arrakis.es

Tom Shackell escribió:
>
> Hi,
>
> I've been trying to create a virtual tree that can view very large
> trees, with a large number of root items. However, I'm finding that
> setItemCount is taking a very long time to execute, even if the items
> aren't currently being viewed. This is on the WIN32 platform.
>
> I've followed the approach described at:
>
> http://www.eclipse.org/articles/Article-SWT-Virtual/Virtual- in-SWT.html
>
> Here is the code I am using:
>
> tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
> tree.addListener(SWT.SetData, new Listener() {
> @Override
> public void handleEvent(Event event) {
> TreeItem item = (TreeItem) event.item;
> String name = "Item " + event.index;
> item.setText(name);
> }
> });
>
> long begin = System.currentTimeMillis();
> tree.setItemCount(70000);
> long end = System.currentTimeMillis();
> System.out.println("Set item count took "+(end-begin)+" ms");
>
> Typical times I am getting for running setItem count are upwards of 30
> seconds, it seems that the even though the tree is virtual setItemCount
> is creating all the items in one go.
>
> Interestingly if I use a Table rather than a tree then there are no
> performance issues at all. However, although this little snippet is
> actually flat, in the actual final program the data will be a tree
> (albeit a very long flat tree, with lots of roots).
>
> So I was wondering whether anyone knew whether this is a known problem,
> and whether there was any workaround to allow the use of large trees?
>
>
> Thanks
>
>
> Tom
>
> ------------------------------------------------------------ ------------
> Cross posted from eclipse.platform.jface, after looking at it closely
> this query isn't actually jface specific so I've reposted on the SWT list.
> ------------------------------------------------------------ ------------


Try this snippet. I tested and works fine!!!


import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

public class TreePopulateLazy {

public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER);
tree.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TreeItem item = (TreeItem) event.item;
TreeItem parentItem = item.getParentItem();
String text = null;
if (parentItem == null) {
text = "node " + tree.indexOf(item);
} else {
text = parentItem.getText() + " - " + parentItem.indexOf(item);
}
item.setText(text);
item.setItemCount(10);
}
});
tree.setItemCount(10000);
shell.setSize(400, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Re: Performance of setItemCount in SWT Tree [message #479308 is a reply to message #479151] Mon, 10 August 2009 15:51 Go to previous messageGo to next message
Eclipse User
Originally posted by: tom-public.shackell.org.uk

Hi Vicente,


I tried your example and it works fine with:

tree.setItemCount(10000);

However, as soon as I try to increase this to 70,000 I get the same
problems as in my test case: the call to setItemCount takes a long time.

The case I'm interested in is created a very large flat tree, with a
large number of roots.


Thanks


Tom


Vicente Rico Guillén wrote:
> Tom Shackell escribió:
>>
>> Hi,
>>
>> I've been trying to create a virtual tree that can view very large
>> trees, with a large number of root items. However, I'm finding that
>> setItemCount is taking a very long time to execute, even if the items
>> aren't currently being viewed. This is on the WIN32 platform.
>>
>> I've followed the approach described at:
>>
>> http://www.eclipse.org/articles/Article-SWT-Virtual/Virtual- in-SWT.html
>>
>> Here is the code I am using:
>>
>> tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
>> tree.addListener(SWT.SetData, new Listener() { @Override
>> public void handleEvent(Event event) {
>> TreeItem item = (TreeItem) event.item;
>> String name = "Item " + event.index;
>> item.setText(name);
>> } });
>> long begin = System.currentTimeMillis();
>> tree.setItemCount(70000);
>> long end = System.currentTimeMillis();
>> System.out.println("Set item count took "+(end-begin)+" ms");
>>
>> Typical times I am getting for running setItem count are upwards of 30
>> seconds, it seems that the even though the tree is virtual setItemCount
>> is creating all the items in one go.
>>
>> Interestingly if I use a Table rather than a tree then there are no
>> performance issues at all. However, although this little snippet is
>> actually flat, in the actual final program the data will be a tree
>> (albeit a very long flat tree, with lots of roots).
>>
>> So I was wondering whether anyone knew whether this is a known problem,
>> and whether there was any workaround to allow the use of large trees?
>>
>>
>> Thanks
>>
>>
>> Tom
>>
>> ------------------------------------------------------------ ------------
>> Cross posted from eclipse.platform.jface, after looking at it closely
>> this query isn't actually jface specific so I've reposted on the SWT
>> list.
>> ------------------------------------------------------------ ------------
>
>
> Try this snippet. I tested and works fine!!!
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Tree;
> import org.eclipse.swt.widgets.TreeItem;
>
> public class TreePopulateLazy {
>
> public static void main(String[] args) {
> Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER);
> tree.addListener(SWT.SetData, new Listener() {
> public void handleEvent(Event event) {
> TreeItem item = (TreeItem) event.item;
> TreeItem parentItem = item.getParentItem();
> String text = null;
> if (parentItem == null) {
> text = "node " + tree.indexOf(item);
> } else {
> text = parentItem.getText() + " - " + parentItem.indexOf(item);
> }
> item.setText(text);
> item.setItemCount(10);
> }
> });
> tree.setItemCount(10000);
> shell.setSize(400, 300);
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
> }
Re: Performance of setItemCount in SWT Tree [message #479737 is a reply to message #479029] Wed, 12 August 2009 09:07 Go to previous messageGo to next message
Andrey Dulub is currently offline Andrey Dulub
Messages: 54
Registered: July 2009
Member
Hi,

Have a look at
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet144.java?view=mark up&content-type=text%2Fvnd.viewcvs-markup&revision=H EAD

You meant 30 seconds or milisecons ? I'm asking because of I got 60-70ms for
1000000 items.

Thnaks,
Andrey Dulub


"Tom Shackell" <tom-public@shackell.org.uk> wrote in message
news:h5jn1l$iaf$1@build.eclipse.org...
>
> Hi,
>
> I've been trying to create a virtual tree that can view very large
> trees, with a large number of root items. However, I'm finding that
> setItemCount is taking a very long time to execute, even if the items
> aren't currently being viewed. This is on the WIN32 platform.
>
> I've followed the approach described at:
>
> http://www.eclipse.org/articles/Article-SWT-Virtual/Virtual- in-SWT.html
>
> Here is the code I am using:
>
> tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
> tree.addListener(SWT.SetData, new Listener() { @Override
> public void handleEvent(Event event) {
> TreeItem item = (TreeItem) event.item;
> String name = "Item " + event.index;
> item.setText(name); } });
> long begin = System.currentTimeMillis();
> tree.setItemCount(70000);
> long end = System.currentTimeMillis();
> System.out.println("Set item count took "+(end-begin)+" ms");
>
> Typical times I am getting for running setItem count are upwards of 30
> seconds, it seems that the even though the tree is virtual setItemCount
> is creating all the items in one go.
>
> Interestingly if I use a Table rather than a tree then there are no
> performance issues at all. However, although this little snippet is
> actually flat, in the actual final program the data will be a tree
> (albeit a very long flat tree, with lots of roots).
>
> So I was wondering whether anyone knew whether this is a known problem,
> and whether there was any workaround to allow the use of large trees?
>
>
> Thanks
>
>
> Tom
>
> ------------------------------------------------------------ ------------
> Cross posted from eclipse.platform.jface, after looking at it closely this
> query isn't actually jface specific so I've reposted on the SWT list.
> ------------------------------------------------------------ ------------
Re: Performance of setItemCount in SWT Tree [message #479842 is a reply to message #479737] Wed, 12 August 2009 17:05 Go to previous message
Eclipse User
Originally posted by: tom-public.shackell.org.uk

Andrey Dulub wrote:
> Hi,
>
> Have a look at
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet144.java?view=mark up&content-type=text%2Fvnd.viewcvs-markup&revision=H EAD
>
> You meant 30 seconds or milisecons ? I'm asking because of I got 60-70ms for
> 1000000 items.
>
> Thnaks,
> Andrey Dulub

Hi,

Yes I've seen that, that's the example for a virtual Table.
Interestingly the Table control performs really well, it's the Tree
control that I'm having trouble with.

No, unfortunately it really does take 30 seconds to call
Tree.setItemCount(100000) :-S

Thanks

Tom
Previous Topic:Drag and drop feedback for Table widget
Next Topic:SWT Label with SWT.WRAP and SWT.CENTER is wrapped, but not centered (Mac OS X)
Goto Forum:
  


Current Time: Wed Oct 22 03:25:00 GMT 2014

Powered by FUDForum. Page generated in 0.01913 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software