[
https://issues.apache.org/jira/browse/FLEX-34759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14333113#comment-14333113
]
Alex Harui commented on FLEX-34759:
-----------------------------------
Thanks for the patch. There was a discussion on the [email protected]
mailing list. It's great to see that you found some optimizations for certain
scenarios. What is troubling is the degradation for the "random" case. For
backward compatibility reasons, I'm concerned that taking this patch would make
some people happy but others unhappy.
First, I want to confirm that your timings were done on a release player with a
release SWF, not a debugger player running a debuggable SWF. If not, can you
get new numbers with such a configuration?
If so, I would like your thoughts on:
1) A further potential optimization where, instead of using:
if (index == length)
you instead use:
if (index == _source.length)
Doing so might break folks who have overridden ArrayList's source property, but
it would be interesting to see if all of the code that runs in the source and
length getters is the culprit for the degradation in the "random" case.
2) Another alternative is that you just contribute a subclass of ArrayList
called something like ArrayListWithFastFirstAndLastAddItem with your
optimizations in that subclass. That way folks who can benefit from your patch
can opt-in, and we know nobody will get burned by any degradations.
Thanks,
-Alex
> 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)