flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "shane doolan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-34759) ArrayList/ArrayCollection performance improvements
Date Mon, 23 Feb 2015 23:14:12 GMT

    [ https://issues.apache.org/jira/browse/FLEX-34759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14334057#comment-14334057
] 

shane doolan commented on FLEX-34759:
-------------------------------------

Hey Alex, thanks for the feedback.

I re-ran the tests on a release player/swf as you suggested (I should have thought of that),
shuffled the logic to give the splice preference in the if-else statements, and reduced the
calls to 'length' with good results. 

\\

* ArrayList.addItemAt is *40x* faster when adding both int's and IEventDispatcher's at the
start/end of the list.
* ArrayList.removeItemAt is 4x faster when removing items from the start of the list, and
over *200x* faster at the end for both both int's and IEventDispatcher's
* Random add/removes are marginally improved, I suspect the odd time it hits the start or
end offsets the extra logic added to check if the splice can be avoided. 

\\

I have attached the new patch.

\\

||label||type||objectCount||addItemAtStart||addItemAtEnd||addItemAtRandom||removeItemAtStart||removeItemAtEnd||removeItemAtRandom||
|Original ArrayList with ints|class ArrayList|100000|2280ms|2311ms|3076ms|2892ms|2309ms|2579ms|
|Original ArrayList with IEventDispatchers|class ArrayList|100000|2341ms|2348ms|3057ms|2931ms|2355ms|2699ms|
|Patched ArrayList with ints|class ArrayListSplicePatch|100000|57ms|54ms|3012ms|658ms|11ms|2502ms|
|Patched ArrayList with IEventDispatchers|class ArrayListSplicePatch|100000|55ms|58ms|3073ms|702ms|31ms|2639ms|
|Patched ArrayList 2 with ints|class ArrayListSplicePatch2|100000|54ms|54ms|3026ms|655ms|11ms|2483ms|
|Patched ArrayList 2 with IEventDispatchers|class ArrayListSplicePatch2|100000|55ms|56ms|3019ms|687ms|29ms|2649ms|

> ArrayList/ArrayCollection performance improvements
> --------------------------------------------------
>
>                 Key: FLEX-34759
>                 URL: https://issues.apache.org/jira/browse/FLEX-34759
>             Project: Apache Flex
>          Issue Type: Improvement
>          Components: Collections
>            Reporter: shane doolan
>              Labels: newbie, patch, performance
>         Attachments: FLEX-34759.patch
>
>
> Considerable performance gains can be achieved by avoiding the use of array splice when
adding/removing items from the start or end of the source array in ArrayList.
> eg/ in ArrayList.addItemAt, replace this:
> {code}
> source.splice(index, 0, item);
> {code}
> with this:   
> {code} 
> if (index == length)
>     source.push(item);
> else if (index == 0)
>     source.unshift(item);
> else
>     source.splice(index, 0, item);
> {code}
> ArrayList.addItem is 10x faster when adding non IEventDispatcher's, and 6x faster for
IEventDispatcher's. There is a small trade-off when performing random access add/removes,
where the extra logic slightly increases the times taken. 
> Since ArrayCollection wraps an ArrayList by default and ArrayCollection.addItem is used
extensively within our apps, this patch has provided considerable performance improvements.
> See profiling results below:
> *Original ArrayList, adding/removing 100k ints*
> * addItemAtStart = "2434ms"
> * addItemAtEnd = "2501ms"
> * addItemAtRandom = "3149ms"
> * removeItemAtStart = "3098ms"
> * removeItemAtEnd = "2401ms"
> * removeItemAtRandom = "2606ms"
> *Original ArrayList, adding/removing 100k IEventDispatcher's*
> * addItemAtStart = "2501ms"
> * addItemAtEnd = "2505ms"
> * addItemAtRandom = "3165ms"
> * removeItemAtStart = "3053ms"
> * removeItemAtEnd = "2453ms"
> * removeItemAtRandom = "2709ms"
> *Patched ArrayList, adding/removing 100k ints*
> * addItemAtStart = "226ms"
> * addItemAtEnd = *"213ms"*
> * addItemAtRandom = "3281ms"
> * removeItemAtStart = "803ms"
> * removeItemAtEnd = "219ms"
> * removeItemAtRandom = "2808ms"
> *Patched ArrayList, adding/removing 100k IEventDispatcher's*
> * addItemAtStart = "415ms"
> * addItemAtEnd = *"488ms"*
> * addItemAtRandom = "3662ms"
> * removeItemAtStart = "878ms"
> * removeItemAtEnd = "264ms"
> * removeItemAtRandom = "2949ms"



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message