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 |
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 |
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 |
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 |
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.
> ------------------------------------------------------------ ------------
|
|
| |
Goto Forum:
Current Time: Fri Apr 19 00:57:23 GMT 2024
Powered by FUDForum. Page generated in 0.01956 seconds
|