Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Table.indexOf not optimized like in SWT
Table.indexOf not optimized like in SWT [message #131085] Mon, 04 May 2009 14:06 Go to next message
Enrico Zanaga is currently offline Enrico ZanagaFriend
Messages: 50
Registered: July 2009
Member
Hi,

I noticed that Table.indexOf in SWT looks like this:

public int indexOf (TableItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (1 <= lastIndexOf && lastIndexOf < count - 1) {
if (items [lastIndexOf] == item) return lastIndexOf;
if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
if (items [lastIndexOf - 1] == item) return --lastIndexOf;
}
if (lastIndexOf < count / 2) {
for (int i=0; i<count; i++) {
if (items [i] == item) return lastIndexOf = i;
}
} else {
for (int i=count - 1; i>=0; --i) {
if (items [i] == item) return lastIndexOf = i;
}
}
return -1;
}


While in RWT looks like:

public int indexOf( final TableItem item ) {
checkWidget();
if( item == null ) {
SWT.error( SWT.ERROR_NULL_ARGUMENT );
}
int result = -1;
for( int i = 0; result == -1 && i < itemCount; i++ ) {
if( items[ i ] == item ) {
result = i;
}
}
return result;
}


In RWT when a list contains 10000 items, the indexOf scroll all over the
10000 items to find the index boosting the CPU at 100%.

Is it possible to optimize the Table.indexOf method like in SWT?

Thanks,
Enrico
Re: Table.indexOf not optimized like in SWT [message #131124 is a reply to message #131085] Mon, 04 May 2009 14:29 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Enrico,

it is already optimized in CVS HEAD :-). See this bug:

273433: [Table] render phase becomes slow when having many Items
https://bugs.eclipse.org/bugs/show_bug.cgi?id=273433

Best,
Ivan

Enrico Zanaga wrote:
> Hi,
>
> I noticed that Table.indexOf in SWT looks like this:
>
> public int indexOf (TableItem item) {
> checkWidget ();
> if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
> int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
> if (1 <= lastIndexOf && lastIndexOf < count - 1) {
> if (items [lastIndexOf] == item) return lastIndexOf;
> if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
> if (items [lastIndexOf - 1] == item) return --lastIndexOf;
> }
> if (lastIndexOf < count / 2) {
> for (int i=0; i<count; i++) {
> if (items [i] == item) return lastIndexOf = i;
> }
> } else {
> for (int i=count - 1; i>=0; --i) {
> if (items [i] == item) return lastIndexOf = i;
> }
> }
> return -1;
> }
>
>
> While in RWT looks like:
>
> public int indexOf( final TableItem item ) {
> checkWidget();
> if( item == null ) {
> SWT.error( SWT.ERROR_NULL_ARGUMENT );
> }
> int result = -1;
> for( int i = 0; result == -1 && i < itemCount; i++ ) {
> if( items[ i ] == item ) {
> result = i;
> }
> }
> return result;
> }
>
>
> In RWT when a list contains 10000 items, the indexOf scroll all over
> the 10000 items to find the index boosting the CPU at 100%.
>
> Is it possible to optimize the Table.indexOf method like in SWT?
>
> Thanks,
> Enrico
Re: Table.indexOf not optimized like in SWT [message #131227 is a reply to message #131124] Mon, 04 May 2009 17:23 Go to previous messageGo to next message
Enrico Zanaga is currently offline Enrico ZanagaFriend
Messages: 50
Registered: July 2009
Member
Hi Ivan,

I've downloaded the version from CVS HEAD, but now the server sends all
the 10000 items of the list to the client.
Now the browser consumes 100% CPU.
In the M6 only the visible rows were send to the client, why not in CSV
HEAD?

Thanks,
Enrico


Ivan Furnadjiev ha scritto:
> Hi Enrico,
>
> it is already optimized in CVS HEAD :-). See this bug:
>
> 273433: [Table] render phase becomes slow when having many Items
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=273433
>
> Best,
> Ivan
>
> Enrico Zanaga wrote:
>> Hi,
>>
>> I noticed that Table.indexOf in SWT looks like this:
>>
>> public int indexOf (TableItem item) {
>> checkWidget ();
>> if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
>> int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
>> if (1 <= lastIndexOf && lastIndexOf < count - 1) {
>> if (items [lastIndexOf] == item) return lastIndexOf;
>> if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
>> if (items [lastIndexOf - 1] == item) return --lastIndexOf;
>> }
>> if (lastIndexOf < count / 2) {
>> for (int i=0; i<count; i++) {
>> if (items [i] == item) return lastIndexOf = i;
>> }
>> } else {
>> for (int i=count - 1; i>=0; --i) {
>> if (items [i] == item) return lastIndexOf = i;
>> }
>> }
>> return -1;
>> }
>>
>>
>> While in RWT looks like:
>>
>> public int indexOf( final TableItem item ) {
>> checkWidget();
>> if( item == null ) {
>> SWT.error( SWT.ERROR_NULL_ARGUMENT );
>> }
>> int result = -1;
>> for( int i = 0; result == -1 && i < itemCount; i++ ) {
>> if( items[ i ] == item ) {
>> result = i;
>> }
>> }
>> return result;
>> }
>>
>>
>> In RWT when a list contains 10000 items, the indexOf scroll all over
>> the 10000 items to find the index boosting the CPU at 100%.
>>
>> Is it possible to optimize the Table.indexOf method like in SWT?
>>
>> Thanks,
>> Enrico
Re: Table.indexOf not optimized like in SWT [message #131241 is a reply to message #131227] Mon, 04 May 2009 18:25 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Enrico,

I did y quick check, but I cannot reproduce what you describe.
Please note that you need to specify the VIRTUAL flag in order to
not have sent all the times to the client.
Please file a bugzilla if you can reproduce the problem.

HTH
Rüdiger

Enrico Zanaga wrote:
> Hi Ivan,
>
> I've downloaded the version from CVS HEAD, but now the server sends all
> the 10000 items of the list to the client.
> Now the browser consumes 100% CPU.
> In the M6 only the visible rows were send to the client, why not in CSV
> HEAD?
>
> Thanks,
> Enrico
>
>
> Ivan Furnadjiev ha scritto:
>> Hi Enrico,
>>
>> it is already optimized in CVS HEAD :-). See this bug:
>>
>> 273433: [Table] render phase becomes slow when having many Items
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=273433
>>
>> Best,
>> Ivan
>>
>> Enrico Zanaga wrote:
>>> Hi,
>>>
>>> I noticed that Table.indexOf in SWT looks like this:
>>>
>>> public int indexOf (TableItem item) {
>>> checkWidget ();
>>> if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
>>> int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
>>> if (1 <= lastIndexOf && lastIndexOf < count - 1) {
>>> if (items [lastIndexOf] == item) return lastIndexOf;
>>> if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
>>> if (items [lastIndexOf - 1] == item) return --lastIndexOf;
>>> }
>>> if (lastIndexOf < count / 2) {
>>> for (int i=0; i<count; i++) {
>>> if (items [i] == item) return lastIndexOf = i;
>>> }
>>> } else {
>>> for (int i=count - 1; i>=0; --i) {
>>> if (items [i] == item) return lastIndexOf = i;
>>> }
>>> }
>>> return -1;
>>> }
>>>
>>>
>>> While in RWT looks like:
>>>
>>> public int indexOf( final TableItem item ) {
>>> checkWidget();
>>> if( item == null ) {
>>> SWT.error( SWT.ERROR_NULL_ARGUMENT );
>>> }
>>> int result = -1;
>>> for( int i = 0; result == -1 && i < itemCount; i++ ) {
>>> if( items[ i ] == item ) {
>>> result = i;
>>> }
>>> }
>>> return result;
>>> }
>>>
>>>
>>> In RWT when a list contains 10000 items, the indexOf scroll all over
>>> the 10000 items to find the index boosting the CPU at 100%.
>>>
>>> Is it possible to optimize the Table.indexOf method like in SWT?
>>>
>>> Thanks,
>>> Enrico
Re: Table.indexOf not optimized like in SWT [message #131254 is a reply to message #131227] Mon, 04 May 2009 18:31 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Enrico,

are you using a virtual table? Can you post a simple snippet that
demonstrate this behavior?

Best,
Ivan

Enrico Zanaga wrote:
> Hi Ivan,
>
> I've downloaded the version from CVS HEAD, but now the server sends
> all the 10000 items of the list to the client.
> Now the browser consumes 100% CPU.
> In the M6 only the visible rows were send to the client, why not in
> CSV HEAD?
>
> Thanks,
> Enrico
>
>
> Ivan Furnadjiev ha scritto:
>> Hi Enrico,
>>
>> it is already optimized in CVS HEAD :-). See this bug:
>>
>> 273433: [Table] render phase becomes slow when having many Items
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=273433
>>
>> Best,
>> Ivan
>>
>> Enrico Zanaga wrote:
>>> Hi,
>>>
>>> I noticed that Table.indexOf in SWT looks like this:
>>>
>>> public int indexOf (TableItem item) {
>>> checkWidget ();
>>> if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
>>> int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
>>> if (1 <= lastIndexOf && lastIndexOf < count - 1) {
>>> if (items [lastIndexOf] == item) return lastIndexOf;
>>> if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
>>> if (items [lastIndexOf - 1] == item) return --lastIndexOf;
>>> }
>>> if (lastIndexOf < count / 2) {
>>> for (int i=0; i<count; i++) {
>>> if (items [i] == item) return lastIndexOf = i;
>>> }
>>> } else {
>>> for (int i=count - 1; i>=0; --i) {
>>> if (items [i] == item) return lastIndexOf = i;
>>> }
>>> }
>>> return -1;
>>> }
>>>
>>>
>>> While in RWT looks like:
>>>
>>> public int indexOf( final TableItem item ) {
>>> checkWidget();
>>> if( item == null ) {
>>> SWT.error( SWT.ERROR_NULL_ARGUMENT );
>>> }
>>> int result = -1;
>>> for( int i = 0; result == -1 && i < itemCount; i++ ) {
>>> if( items[ i ] == item ) {
>>> result = i;
>>> }
>>> }
>>> return result;
>>> }
>>>
>>>
>>> In RWT when a list contains 10000 items, the indexOf scroll all over
>>> the 10000 items to find the index boosting the CPU at 100%.
>>>
>>> Is it possible to optimize the Table.indexOf method like in SWT?
>>>
>>> Thanks,
>>> Enrico
Previous Topic:Singlesourcing Branding (Splashscreen)
Next Topic:Work with RAP
Goto Forum:
  


Current Time: Thu Apr 25 12:50:24 GMT 2024

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

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

Back to the top