<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Drunk on Software Episode 3 &#8211; Performance Pitfalls of Flex’s ArrayCollection</title>
	<atom:link href="http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection</link>
	<description>Heroku &#124; Java &#124; Scala &#124; Cloud &#124; Open Source &#124; Linux</description>
	<lastBuildDate>Wed, 08 Feb 2012 21:29:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Cedric Orcellet</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-164906</link>
		<dc:creator>Cedric Orcellet</dc:creator>
		<pubDate>Tue, 17 Jan 2012 10:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-164906</guid>
		<description>What about that ? :

true

Default value is false. When true, instances of java.util.Collection are returned as ActionScript arrays. When false, inxtances of java.util.Collection are returned as mx.collections.ArrayCollection.</description>
		<content:encoded><![CDATA[<p>What about that ? :</p>
<p>true</p>
<p>Default value is false. When true, instances of java.util.Collection are returned as ActionScript arrays. When false, inxtances of java.util.Collection are returned as mx.collections.ArrayCollection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ward</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133555</link>
		<dc:creator>James Ward</dc:creator>
		<pubDate>Sat, 29 Nov 2008 05:59:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133555</guid>
		<description>Hi Joey,

XML works fine when you have small data sets and do not control what is on the other side.  In this case I&#039;d stick with what works best which is probably Flex with ArrayCollections.

-James</description>
		<content:encoded><![CDATA[<p>Hi Joey,</p>
<p>XML works fine when you have small data sets and do not control what is on the other side.  In this case I&#8217;d stick with what works best which is probably Flex with ArrayCollections.</p>
<p>-James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joey</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133551</link>
		<dc:creator>Joey</dc:creator>
		<pubDate>Sat, 29 Nov 2008 04:38:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133551</guid>
		<description>Hi James,
First off, thank you for sharing. - Second, I am totally confused when it comes to AMF. Unfortunately, I don&#039;t have the option of installing additional software such as LCDS, BlazeDS, OrbWeb, etc... so there is no way for me to test AMF that I am aware of. 

I built a simple reporting app for my department. Presently, I use the webservice component and hook it up to a .NET webservice. Depending on the webservice it will return either an ArrayList of objects or a DataTable. In either case, Flex populates an Array (ArrayList) and an ArrayCollection(DataTable) which is then used for databinding. My questions to you are ... 

1. ArrayList or DataTable - which would you prefer when using/not using AMF?

2. Is my approach correct? If not, what approach would you take? Using my approach, which would yield better results - with/without AMF?

3. When creating an app with features such as friends list, photo sharing, etc.... would you recommend using Flex? If so, with/without AMF, and using an array or arrayCollection?</description>
		<content:encoded><![CDATA[<p>Hi James,<br />
First off, thank you for sharing. &#8211; Second, I am totally confused when it comes to AMF. Unfortunately, I don&#8217;t have the option of installing additional software such as LCDS, BlazeDS, OrbWeb, etc&#8230; so there is no way for me to test AMF that I am aware of. </p>
<p>I built a simple reporting app for my department. Presently, I use the webservice component and hook it up to a .NET webservice. Depending on the webservice it will return either an ArrayList of objects or a DataTable. In either case, Flex populates an Array (ArrayList) and an ArrayCollection(DataTable) which is then used for databinding. My questions to you are &#8230; </p>
<p>1. ArrayList or DataTable &#8211; which would you prefer when using/not using AMF?</p>
<p>2. Is my approach correct? If not, what approach would you take? Using my approach, which would yield better results &#8211; with/without AMF?</p>
<p>3. When creating an app with features such as friends list, photo sharing, etc&#8230;. would you recommend using Flex? If so, with/without AMF, and using an array or arrayCollection?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ward</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133363</link>
		<dc:creator>James Ward</dc:creator>
		<pubDate>Thu, 27 Nov 2008 21:26:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133363</guid>
		<description>&lt;a href=&quot;#comment-133350&quot; rel=&quot;nofollow&quot;&gt;@Bruce&lt;/a&gt; 

The scenario in which the problem was discovered is a very large project with thousands of classes in an object graph.  When an initial request at application startup is made to the server hundreds of thousands of objects are turned into AMF and sent back to the Flex applications.  The deserialization was taking a very long time on the client.  The reason turned out to be the amount of time it takes to instantiate and add items to ArrayCollections.  Arrays are much faster but require a lot of extra work to deal with.  There is not a good way to specify which collections should use Arrays and which should use ArrayCollections.  Also creating custom serialization (read/write External) would be way too much work.  Ideally Flex would deal with this scenario in a more efficient manner.

-James</description>
		<content:encoded><![CDATA[<p><a href="#comment-133350" rel="nofollow">@Bruce</a> </p>
<p>The scenario in which the problem was discovered is a very large project with thousands of classes in an object graph.  When an initial request at application startup is made to the server hundreds of thousands of objects are turned into AMF and sent back to the Flex applications.  The deserialization was taking a very long time on the client.  The reason turned out to be the amount of time it takes to instantiate and add items to ArrayCollections.  Arrays are much faster but require a lot of extra work to deal with.  There is not a good way to specify which collections should use Arrays and which should use ArrayCollections.  Also creating custom serialization (read/write External) would be way too much work.  Ideally Flex would deal with this scenario in a more efficient manner.</p>
<p>-James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133350</link>
		<dc:creator>Bruce</dc:creator>
		<pubDate>Thu, 27 Nov 2008 17:32:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133350</guid>
		<description>Okay, so I&#039;m not sure which you&#039;re trying to prove.  1) ArrayCollection vs Array performance is vastly different or 2) The flex serialization engine does not perform as well for Arrays as it does for ArrayCollections?  or are you saying because the addItem on ArrayCollection is slow then all operations on the ArrayCollection are slow?

if 1, i think we can safely say you can use the source array element (when you have large datasets) and get a close comparison of the performance an array gets you.
if 2, then you should investigate whether there is performance issues with ArrayCollection serialization vs Array serializations.  I would bet you would be quite amazed that the underlying serialization method of readExternal doesn&#039;t use addItem or addItemAt but probably serializes the source data which is actually most likely an array. I would bet the ArrayList is even like this. 

So I did a performance test based upon your code but changed the addItem to the .source = myA, then I added the writeObject &amp; readObject of the data.  And wouldn&#039;t you know it it&#039;s about 65 millis difference between the two.  

Anyway I&#039;m posting the updated source code



    

    

    

    

    

    
        
            
        

        
            

            

            

            

            
        

        
            
                &lt;![CDATA[
                var i:int;
                myA = [];
                myAC.removeAll();
                myACNAU.disableAutoUpdate();
                myDBAC.removeAll();
                myDDBAC.removeAll();

                var startTime:Date = new Date();
                var b:ByteArray = new ByteArray();
                if( useA.selected )
                {
                    for( i = 0 ; i &lt; numObjects.value ; i++ )
                    {
                        myA.push({prop1:&#039;asdf&#039;, prop2:startTime, prop3:i});
                    }
                    b.writeObject(myA);
                }
                else if( useAC.selected )
                {
                    for( i = 0 ; i &lt; numObjects.value ; i++ )
                    {
                        myA.push({prop1:&#039;asdf&#039;, prop2:startTime, prop3:i});
                    }
                    myAC.source = myA;
                    myAC.refresh();
                    b.writeObject(myAC);
                }
                else if( useACNAU.selected )
                {
                    
                    for( i = 0 ; i &lt; numObjects.value ; i++ )
                    {
                        myA.push({prop1:&#039;asdf&#039;, prop2:startTime, prop3:i});
                    }
                    myACNAU.source = myA;
                    myACNAU.refresh();
                    b.writeObject(myACNAU);
                }
                else if( useDBAC.selected )
                {
                    for( i = 0 ; i &lt; numObjects.value ; i++ )
                    {
                        myA.push({prop1:&#039;asdf&#039;, prop2:startTime, prop3:i});
                    }
                    myDBAC.source = myA;
                    myDBAC.refresh();
                    b.writeObject(myDBAC);
                }
                else if( useDDBAC.selected )
                {
                    for( i = 0 ; i 
            
        

        
    

    

    

    



&lt;a href=&quot;#comment-133338&quot; rel=&quot;nofollow&quot;&gt;@James Ward&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Okay, so I&#8217;m not sure which you&#8217;re trying to prove.  1) ArrayCollection vs Array performance is vastly different or 2) The flex serialization engine does not perform as well for Arrays as it does for ArrayCollections?  or are you saying because the addItem on ArrayCollection is slow then all operations on the ArrayCollection are slow?</p>
<p>if 1, i think we can safely say you can use the source array element (when you have large datasets) and get a close comparison of the performance an array gets you.<br />
if 2, then you should investigate whether there is performance issues with ArrayCollection serialization vs Array serializations.  I would bet you would be quite amazed that the underlying serialization method of readExternal doesn&#8217;t use addItem or addItemAt but probably serializes the source data which is actually most likely an array. I would bet the ArrayList is even like this. </p>
<p>So I did a performance test based upon your code but changed the addItem to the .source = myA, then I added the writeObject &amp; readObject of the data.  And wouldn&#8217;t you know it it&#8217;s about 65 millis difference between the two.  </p>
<p>Anyway I&#8217;m posting the updated source code</p>
<p>                &lt;![CDATA[<br />
                var i:int;<br />
                myA = [];<br />
                myAC.removeAll();<br />
                myACNAU.disableAutoUpdate();<br />
                myDBAC.removeAll();<br />
                myDDBAC.removeAll();</p>
<p>                var startTime:Date = new Date();<br />
                var b:ByteArray = new ByteArray();<br />
                if( useA.selected )<br />
                {<br />
                    for( i = 0 ; i &lt; numObjects.value ; i++ )<br />
                    {<br />
                        myA.push({prop1:&#8217;asdf&#8217;, prop2:startTime, prop3:i});<br />
                    }<br />
                    b.writeObject(myA);<br />
                }<br />
                else if( useAC.selected )<br />
                {<br />
                    for( i = 0 ; i &lt; numObjects.value ; i++ )<br />
                    {<br />
                        myA.push({prop1:&#8217;asdf&#8217;, prop2:startTime, prop3:i});<br />
                    }<br />
                    myAC.source = myA;<br />
                    myAC.refresh();<br />
                    b.writeObject(myAC);<br />
                }<br />
                else if( useACNAU.selected )<br />
                {</p>
<p>                    for( i = 0 ; i &lt; numObjects.value ; i++ )<br />
                    {<br />
                        myA.push({prop1:&#8217;asdf&#8217;, prop2:startTime, prop3:i});<br />
                    }<br />
                    myACNAU.source = myA;<br />
                    myACNAU.refresh();<br />
                    b.writeObject(myACNAU);<br />
                }<br />
                else if( useDBAC.selected )<br />
                {<br />
                    for( i = 0 ; i &lt; numObjects.value ; i++ )<br />
                    {<br />
                        myA.push({prop1:&#8217;asdf&#8217;, prop2:startTime, prop3:i});<br />
                    }<br />
                    myDBAC.source = myA;<br />
                    myDBAC.refresh();<br />
                    b.writeObject(myDBAC);<br />
                }<br />
                else if( useDDBAC.selected )<br />
                {<br />
                    for( i = 0 ; i </p>
<p><a href="#comment-133338" rel="nofollow">@James Ward</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ward</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133341</link>
		<dc:creator>James Ward</dc:creator>
		<pubDate>Thu, 27 Nov 2008 16:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133341</guid>
		<description>Hi Alex,

You might not be using large datasets and complex objects graphs but there are certainly many out there who do.  My friend Jon encountered this problem on a real project.

-James</description>
		<content:encoded><![CDATA[<p>Hi Alex,</p>
<p>You might not be using large datasets and complex objects graphs but there are certainly many out there who do.  My friend Jon encountered this problem on a real project.</p>
<p>-James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ward</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133338</link>
		<dc:creator>James Ward</dc:creator>
		<pubDate>Thu, 27 Nov 2008 16:21:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133338</guid>
		<description>Hi Bruce,

See the comment above.  The problem is that you have very little control over how AMF collections are deserialized.

-James</description>
		<content:encoded><![CDATA[<p>Hi Bruce,</p>
<p>See the comment above.  The problem is that you have very little control over how AMF collections are deserialized.</p>
<p>-James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133293</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 27 Nov 2008 09:42:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133293</guid>
		<description>I never got a real life situation where I need 100.000 Array instances? Do you? I think a more realistic benchmark would be with 1000 object, and for shure that are many objects.

Greetz
Alex</description>
		<content:encoded><![CDATA[<p>I never got a real life situation where I need 100.000 Array instances? Do you? I think a more realistic benchmark would be with 1000 object, and for shure that are many objects.</p>
<p>Greetz<br />
Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133223</link>
		<dc:creator>Bruce</dc:creator>
		<pubDate>Wed, 26 Nov 2008 19:22:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133223</guid>
		<description>Have you tried creating the array and assigning the arrayCollection.source to this newly created array and publishing the change of the array collection with ArrayCollection.refresh().  This should get you very very close to Array insert speeds and still give you the events that we so much like with the ArrayCollection.  From what I&#039;ve seen the ugliness is in ArrayList with addItem.  Event though the ArrayCollection has disableAutoUpdates that just ensures the auto updates are not fired via the ArrayCollection, but since the ArrayList fires events to the ArrayCollection the array collection just doesn&#039;t pass this update along and is still listening when disableAutoUpdates has been activated.  If you use this method you shouldn&#039;t have ugliness with the ArrayCollection, if you have something coming from a server (and I believe there is a different kind of list that is created from a server side that replaces the ArrayList) you can have it transported as an Array and then assign the array to .source of an ArrayCollection or hope for the best that the implementation of the ArrayCollection&#039;s list implementation is different or that it doesn&#039;t use addItem/addItemAt.</description>
		<content:encoded><![CDATA[<p>Have you tried creating the array and assigning the arrayCollection.source to this newly created array and publishing the change of the array collection with ArrayCollection.refresh().  This should get you very very close to Array insert speeds and still give you the events that we so much like with the ArrayCollection.  From what I&#8217;ve seen the ugliness is in ArrayList with addItem.  Event though the ArrayCollection has disableAutoUpdates that just ensures the auto updates are not fired via the ArrayCollection, but since the ArrayList fires events to the ArrayCollection the array collection just doesn&#8217;t pass this update along and is still listening when disableAutoUpdates has been activated.  If you use this method you shouldn&#8217;t have ugliness with the ArrayCollection, if you have something coming from a server (and I believe there is a different kind of list that is created from a server side that replaces the ArrayList) you can have it transported as an Array and then assign the array to .source of an ArrayCollection or hope for the best that the implementation of the ArrayCollection&#8217;s list implementation is different or that it doesn&#8217;t use addItem/addItemAt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ward</title>
		<link>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performance-pitfalls-of-flexs-arraycollection/comment-page-1/#comment-133069</link>
		<dc:creator>James Ward</dc:creator>
		<pubDate>Tue, 25 Nov 2008 00:04:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesward.com/wordpress/?p=583#comment-133069</guid>
		<description>Perfect then.  We will probably be switching to blip.tv which has iTunes support.</description>
		<content:encoded><![CDATA[<p>Perfect then.  We will probably be switching to blip.tv which has iTunes support.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

