<?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: AS3 Performance Optimization</title>
	<atom:link href="http://www.richnetapps.com/as3-performance-optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richnetapps.com/as3-performance-optimization/</link>
	<description>Internet Applications - Flash, Flex, Silverlight, JavaFX</description>
	<lastBuildDate>Fri, 02 Dec 2011 23:04:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: JP</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-788</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Sat, 06 Nov 2010 10:18:24 +0000</pubDate>
		<guid isPermaLink="false">#comment-788</guid>
		<description>Great post. I keep reading &quot;Don’t optimize early&quot; on many optimization advices but I keep thinking it&#039;s the righ way for very experimented programmers.

Note that the comment by &quot;iPhone&quot; is obviously a comment just to improve the SEO of his site ;)</description>
		<content:encoded><![CDATA[<p>Great post. I keep reading &#8220;Don’t optimize early&#8221; on many optimization advices but I keep thinking it&#8217;s the righ way for very experimented programmers.</p>
<p>Note that the comment by &#8220;iPhone&#8221; is obviously a comment just to improve the SEO of his site <img src='http://www.richnetapps.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Armand Niculescu</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-578</link>
		<dc:creator>Armand Niculescu</dc:creator>
		<pubDate>Thu, 22 Oct 2009 19:18:32 +0000</pubDate>
		<guid isPermaLink="false">#comment-578</guid>
		<description>Dave, in your specific example, yes, the first method is faster. This shows that for simple cases, the compiler is clever enough to optimize the code by itself.
However, instead of using that simple array, generate one, like this:
for (i=0; i&lt;50000; i++)
&lt;code&gt;{
	aa = new Array();
	for (j=0; j&lt;100; j++)
		aa[j]=&quot;a&quot;+j;
	a[i]=aa;
}&lt;/code&gt;
The second method becomes significantly faster (in my case 41ms vs 25ms for 50000 iterations).

I have some notes from Werner Sharp,  an Adobe engineer on this matter, who helped me improve the performance of my &lt;a href=&quot;http://www.flashchess3.com&quot; rel=&quot;nofollow&quot;&gt;chess game&lt;/a&gt;. The increase in speed was dramatic.

To quote Mr. Sharp (a little out of context): &quot; &lt;em&gt;The player does not know the type of the array so it goes through a much slower method.  It’s not the objects in the array but the array reference itself. [...] For arrays whose element are untyped, just make sure you type them when you retrieve the value.
&lt;code&gt;var x:MyType = myarray[i].property&lt;/code&gt;
becomes
&lt;code&gt;var t:MyObject = myarray[i];
var x:MyType = t.property;&lt;/code&gt;

In FP10, you could use the Vector object for type safety and performance.&lt;/em&gt;&quot;

I couldn&#039;t use Vector at the time.

Also have a look at http://www.adobe.com/devnet/flex/articles/as3_tuning/fm_as3perf.pdf  </description>
		<content:encoded><![CDATA[<p>Dave, in your specific example, yes, the first method is faster. This shows that for simple cases, the compiler is clever enough to optimize the code by itself.<br />
However, instead of using that simple array, generate one, like this:<br />
for (i=0; i&lt;50000; i++)<br />
<code>{<br />
	aa = new Array();<br />
	for (j=0; j&lt;100; j++)<br />
		aa[j]="a"+j;<br />
	a[i]=aa;<br />
}</code><br />
The second method becomes significantly faster (in my case 41ms vs 25ms for 50000 iterations).</p>
<p>I have some notes from Werner Sharp,  an Adobe engineer on this matter, who helped me improve the performance of my <a href="http://www.flashchess3.com" rel="nofollow">chess game</a>. The increase in speed was dramatic.</p>
<p>To quote Mr. Sharp (a little out of context): &#8221; <em>The player does not know the type of the array so it goes through a much slower method.  It’s not the objects in the array but the array reference itself. [...] For arrays whose element are untyped, just make sure you type them when you retrieve the value.<br />
<code>var x:MyType = myarray[i].property</code><br />
becomes<br />
<code>var t:MyObject = myarray[i];<br />
var x:MyType = t.property;</code></p>
<p>In FP10, you could use the Vector object for type safety and performance.</em>&#8221;</p>
<p>I couldn&#8217;t use Vector at the time.</p>
<p>Also have a look at <a href="http://www.adobe.com/devnet/flex/articles/as3_tuning/fm_as3perf.pdf" rel="nofollow">http://www.adobe.com/devnet/flex/articles/as3_tuning/fm_as3perf.pdf</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-577</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 22 Oct 2009 18:38:48 +0000</pubDate>
		<guid isPermaLink="false">#comment-577</guid>
		<description>Thanks for the tips! The one about keeping strongly typed with arrays seems wrong however - I did various tests of this one and I always am getting better performance when I do like: b = myArray[n][i]; instead of the two line method you showed. Here&#039;s a super simple test:

var b:int;
var a:Array = new Array([50,50,50],[20,20,20],[30,30,30],[10,10,10]);
var aa:Array = new Array();

d = getTimer();
for(i = 0; i &lt; 5000000; i++){	
	b = a[2][2];
}
e = getTimer() - d;


d = getTimer();
for(i = 0; i &lt; 5000000; i++){	
	aa = a[2];
	b = aa[2];
}
f = getTimer() - d;
trace(e,f);

e is always coming out faster?</description>
		<content:encoded><![CDATA[<p>Thanks for the tips! The one about keeping strongly typed with arrays seems wrong however &#8211; I did various tests of this one and I always am getting better performance when I do like: b = myArray[n][i]; instead of the two line method you showed. Here&#8217;s a super simple test:</p>
<p>var b:int;<br />
var a:Array = new Array([50,50,50],[20,20,20],[30,30,30],[10,10,10]);<br />
var aa:Array = new Array();</p>
<p>d = getTimer();<br />
for(i = 0; i &lt; 5000000; i++){<br />
	b = a[2][2];<br />
}<br />
e = getTimer() &#8211; d;</p>
<p>d = getTimer();<br />
for(i = 0; i &lt; 5000000; i++){<br />
	aa = a[2];<br />
	b = aa[2];<br />
}<br />
f = getTimer() &#8211; d;<br />
trace(e,f);</p>
<p>e is always coming out faster?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-538</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Tue, 26 May 2009 20:22:02 +0000</pubDate>
		<guid isPermaLink="false">#comment-538</guid>
		<description>Great article.  I was wondering if you had any insight into using the array utilities such as array.getIndex() if they are faster then looping through the array and comparing the values?  Or maybe  you have some tips about combining arrays without entering duplicate values?

Thanks in advance!

&lt;strong&gt;Armand:&lt;/strong&gt; &lt;code&gt;.getIndex()&lt;/code&gt; is indeed faster than looping. I don&#039;t have benchmark info nearby but it&#039;s difinitely noticeable. However, other methods such as &lt;code&gt;Array.map()&lt;/code&gt; or &lt;code&gt;.every()&lt;/code&gt; or &lt;code&gt;.some()&lt;/code&gt; are rather slow.</description>
		<content:encoded><![CDATA[<p>Great article.  I was wondering if you had any insight into using the array utilities such as array.getIndex() if they are faster then looping through the array and comparing the values?  Or maybe  you have some tips about combining arrays without entering duplicate values?</p>
<p>Thanks in advance!</p>
<p><strong>Armand:</strong> <code>.getIndex()</code> is indeed faster than looping. I don&#8217;t have benchmark info nearby but it&#8217;s difinitely noticeable. However, other methods such as <code>Array.map()</code> or <code>.every()</code> or <code>.some()</code> are rather slow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blogger Indramayu</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-537</link>
		<dc:creator>Blogger Indramayu</dc:creator>
		<pubDate>Sat, 23 May 2009 10:45:10 +0000</pubDate>
		<guid isPermaLink="false">#comment-537</guid>
		<description>Thanks for share. I need this.</description>
		<content:encoded><![CDATA[<p>Thanks for share. I need this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iPhone</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-171</link>
		<dc:creator>iPhone</dc:creator>
		<pubDate>Tue, 24 Feb 2009 02:17:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-171</guid>
		<description>Thanks for the great post..It covers a lots of topics and got to know so much about coding through this..Keep up the good work and i will be looking for some more such posts on your blog.</description>
		<content:encoded><![CDATA[<p>Thanks for the great post..It covers a lots of topics and got to know so much about coding through this..Keep up the good work and i will be looking for some more such posts on your blog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NoelB</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-170</link>
		<dc:creator>NoelB</dc:creator>
		<pubDate>Tue, 09 Dec 2008 11:46:49 +0000</pubDate>
		<guid isPermaLink="false">#comment-170</guid>
		<description>I haven&#039;t spent much time with flash 10, but it&#039;s amazing to hear that simply typing the elements of an array will grant you similar performance as using vectors in flash 10. Great collection of tips, thanks for the post.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t spent much time with flash 10, but it&#8217;s amazing to hear that simply typing the elements of an array will grant you similar performance as using vectors in flash 10. Great collection of tips, thanks for the post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.richnetapps.com/as3-performance-optimization/comment-page-1/#comment-169</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Fri, 28 Nov 2008 04:20:38 +0000</pubDate>
		<guid isPermaLink="false">#comment-169</guid>
		<description>Very nice article. I really like that you are putting emphasis on the &#039;don&#8217;t optimize early&#039; and the &#039;do you need to optimize&#039; parts.&lt;br /&gt;
&lt;br /&gt;
It would be nice if we had an ActionScript pre compiler who would make these kinds of optimalizations before actualy compiling code. Who knows, someone might feel up to it, hehe.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Greetz Erik</description>
		<content:encoded><![CDATA[<p>Very nice article. I really like that you are putting emphasis on the &#8216;don&#8217;t optimize early&#8217; and the &#8216;do you need to optimize&#8217; parts.</p>
<p>It would be nice if we had an ActionScript pre compiler who would make these kinds of optimalizations before actualy compiling code. Who knows, someone might feel up to it, hehe.</p>
<p>
Greetz Erik</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced

Served from: www.richnetapps.com @ 2012-02-07 14:58:54 -->
