Return-Path: X-Original-To: apmail-flex-issues-archive@minotaur.apache.org Delivered-To: apmail-flex-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0056717B4A for ; Fri, 20 Feb 2015 01:03:26 +0000 (UTC) Received: (qmail 19476 invoked by uid 500); 20 Feb 2015 01:03:26 -0000 Delivered-To: apmail-flex-issues-archive@flex.apache.org Received: (qmail 19390 invoked by uid 500); 20 Feb 2015 01:03:26 -0000 Mailing-List: contact issues-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list issues@flex.apache.org Received: (qmail 19377 invoked by uid 99); 20 Feb 2015 01:03:26 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Feb 2015 01:03:26 +0000 Date: Fri, 20 Feb 2015 01:03:26 +0000 (UTC) From: "shane doolan (JIRA)" To: issues@flex.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (FLEX-34759) ArrayList performance improvements MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLEX-34759?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] shane doolan updated FLEX-34759: -------------------------------- Description: 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 The trade-off is for purely random add/removes, where the extra logic increases the times taken slightly. For us, addItem is the major use case - this patch speeds up population of all of our ArrayCollections considerably. 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" was: 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: source.splice(index, 0, item); With this: if (index == length) source.push(item); else if (index == 0) source.unshift(item); else source.splice(index, 0, item); addItem is 10x faster when adding non IEventDispatcher's, and 6x faster for IEventDispatcher's The trade-off is for purely random add/removes, where the extra logic increases the times taken slightly. For us, addItem is the major use case - this patch speeds up population of all of our ArrayCollections considerably. Patch in on its way, 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" > ArrayList 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 > The trade-off is for purely random add/removes, where the extra logic increases the times taken slightly. For us, addItem is the major use case - this patch speeds up population of all of our ArrayCollections considerably. > 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)