<?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: Function Performance</title>
	<atom:link href="http://jacksondunstan.com/articles/413/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/413</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Tue, 07 Feb 2012 09:30:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-13792</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Sun, 09 Oct 2011 01:37:15 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-13792</guid>
		<description>All good ideas for a follow-up article. :)</description>
		<content:encoded><![CDATA[<p>All good ideas for a follow-up article. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: skyboy</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-13791</link>
		<dc:creator>skyboy</dc:creator>
		<pubDate>Sun, 09 Oct 2011 01:18:43 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-13791</guid>
		<description>I posted the code/results and SWF in this thread: http://kongregate.com/forums/4/topics/211152

Includes some 10.3 results (which you missed doing an update on). Should get a really good representative sample of performance across platforms and CPUs (some really high end machines, low end machines like mine, various windows versions, linux. maybe some macs).</description>
		<content:encoded><![CDATA[<p>I posted the code/results and SWF in this thread: <a href="http://kongregate.com/forums/4/topics/211152" rel="nofollow">http://kongregate.com/forums/4/topics/211152</a></p>
<p>Includes some 10.3 results (which you missed doing an update on). Should get a really good representative sample of performance across platforms and CPUs (some really high end machines, low end machines like mine, various windows versions, linux. maybe some macs).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: skyboy</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-13784</link>
		<dc:creator>skyboy</dc:creator>
		<pubDate>Sat, 08 Oct 2011 22:42:42 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-13784</guid>
		<description>There are a couple test cases missing for this: a reference function var (not local, and shouldn&#039;t be included in the dynamic function tests to avoid the overhead; plain should be moved out) and apply/call.

I just did the test to find out if caching apple/call would result in a speed up (in FP11: no. apply/call are the same speed as a dynamic call when using the dot notation). I just did a test, added the missing ones and graphed it, here: http://i.imgur.com/9ElgF.png with the code: http://pastebin.com/gyQ9swJD</description>
		<content:encoded><![CDATA[<p>There are a couple test cases missing for this: a reference function var (not local, and shouldn&#8217;t be included in the dynamic function tests to avoid the overhead; plain should be moved out) and apply/call.</p>
<p>I just did the test to find out if caching apple/call would result in a speed up (in FP11: no. apply/call are the same speed as a dynamic call when using the dot notation). I just did a test, added the missing ones and graphed it, here: <a href="http://i.imgur.com/9ElgF.png" rel="nofollow">http://i.imgur.com/9ElgF.png</a> with the code: <a href="http://pastebin.com/gyQ9swJD" rel="nofollow">http://pastebin.com/gyQ9swJD</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dimuMurray</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-10695</link>
		<dc:creator>dimuMurray</dc:creator>
		<pubDate>Sun, 14 Aug 2011 20:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-10695</guid>
		<description>^ Should have read &quot;How about &lt;strong&gt;invoking&lt;/strong&gt; functions via the index operator&quot;</description>
		<content:encoded><![CDATA[<p>^ Should have read &#8220;How about <strong>invoking</strong> functions via the index operator&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dimuMurray</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-10693</link>
		<dc:creator>dimuMurray</dc:creator>
		<pubDate>Sun, 14 Aug 2011 20:11:43 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-10693</guid>
		<description>How about accessing functions via the index operator?

Something like this:
&lt;pre lang=&quot;actionscript3&quot;&gt;
objectInstance[&quot;functionName&quot;](param1, param2, ...);
&lt;/pre&gt;

Too slow?</description>
		<content:encoded><![CDATA[<p>How about accessing functions via the index operator?</p>
<p>Something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">objectInstance<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;functionName&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span>param1<span style="color: #000066; font-weight: bold;">,</span> param2<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">...</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Too slow?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-8096</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 24 Jun 2011 22:03:10 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-8096</guid>
		<description>No worries, we all make mistakes from time to time. My article this week included a silly typo that forced me to rewrite most of it. It&#039;s no biggie. :)

As for your test results, they&#039;re pretty much the same as my results except for the getters and setters. Keep in mind that the iPhone 4 is running a single-core 800 Mhz ARM chip and my test machine in the article was a 3.0 Ghz Intel Core 2 Duo. The iPhone&#039;s also got an 800 Mhz memory bus compared to the 1066 Mhz dual-channel memory bus on the desktop test machine. Given such a huge hardware advantage on the side of the test machine from the article, I don&#039;t think it&#039;s so unreasonable to expect an order of magnitude less performance out of the iPhone. Still, you&#039;re seeing a ~50x slowdown, so there&#039;s a good chance that more is going on here. Perhaps the compiler used to compile the Flash Player VM is not as optimized for ARM as it is for x86. For example, Flash Player may be compiled with Intel&#039;s highly-optimized compiler when targeting x86 and the much-slower GCC may be used when targeting ARM. Together, these hardware and software differences alone may be responsible for the difference.

Thanks for the performance numbers!</description>
		<content:encoded><![CDATA[<p>No worries, we all make mistakes from time to time. My article this week included a silly typo that forced me to rewrite most of it. It&#8217;s no biggie. :)</p>
<p>As for your test results, they&#8217;re pretty much the same as my results except for the getters and setters. Keep in mind that the iPhone 4 is running a single-core 800 Mhz ARM chip and my test machine in the article was a 3.0 Ghz Intel Core 2 Duo. The iPhone&#8217;s also got an 800 Mhz memory bus compared to the 1066 Mhz dual-channel memory bus on the desktop test machine. Given such a huge hardware advantage on the side of the test machine from the article, I don&#8217;t think it&#8217;s so unreasonable to expect an order of magnitude less performance out of the iPhone. Still, you&#8217;re seeing a ~50x slowdown, so there&#8217;s a good chance that more is going on here. Perhaps the compiler used to compile the Flash Player VM is not as optimized for ARM as it is for x86. For example, Flash Player may be compiled with Intel&#8217;s highly-optimized compiler when targeting x86 and the much-slower GCC may be used when targeting ARM. Together, these hardware and software differences alone may be responsible for the difference.</p>
<p>Thanks for the performance numbers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP Stringham</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-8094</link>
		<dc:creator>JP Stringham</dc:creator>
		<pubDate>Fri, 24 Jun 2011 21:19:28 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-8094</guid>
		<description>Sorry about that. You&#039;re absolutely right. Also the discrepancy in my first test for Final functions was because NUM_ITERATIONS still existed as a local field. Please (if possible) delete or severely edit my first post. Here are updated, more accurate numbers.

Again this is still with NUM_ITERATIONS set to 1000000, one order of magnitude. I have triple checked and this is now consistent with all tests - what I&#039;ve done is set NUM_ITERATIONS as a local const and then done a local function &#039;cache&#039; as you illustrated in your linked post where within the function, eg:

&lt;pre lang=&quot;actionscript3&quot;&gt;
private const NUM_ITERATIONS:int = 1000000;

private function testDynamicFunctions(ev:Event): void
{
	const NUM_ITERATIONS:int = this.NUM_ITERATIONS;
	var beforeTime:int;
	var i:int;
&lt;/pre&gt;

I humbly and profusely apologize for the horrible misinformation prior. It is still disappointing, however the performance drop is not nearly as jarring as before!

Plain: 6660
Local: 2335
Function var: 2307

Private: 245
Protected: 241
Internal: 238
Public: 247

this.Private: 237
this.Protected: 241
this.Internal: 238
this.Public: 232

Static private: 354
Static protected: 268
Static internal: 271
Static public: 261

Override protected: 236
Override internal: 246
Override public: 242

Super protected: 227
Super internal: 282
Super public: 294

Interface direct: 226
Interface via interface: 276
Interface via class: 222

Private Get: 234
Protected Get: 225
Internal Get: 222
Public Get: 222

Private Set: 2489
Protected Set: 5797
Internal Set: 2382
Public Set: 2505

Final Private: 244
Final Protected: 252
Final Internal: 288
Final Public: 352

Final Override protected: 226
Final Override internal: 223
Final Override public: 224

I performed these tests three times. Once I saw an anomalous doubling of this.Private, but that did not occur 2/3 times. However Protected Set is consistently twice as slow as its Internal, Private and Public counterparts.</description>
		<content:encoded><![CDATA[<p>Sorry about that. You&#8217;re absolutely right. Also the discrepancy in my first test for Final functions was because NUM_ITERATIONS still existed as a local field. Please (if possible) delete or severely edit my first post. Here are updated, more accurate numbers.</p>
<p>Again this is still with NUM_ITERATIONS set to 1000000, one order of magnitude. I have triple checked and this is now consistent with all tests &#8211; what I&#8217;ve done is set NUM_ITERATIONS as a local const and then done a local function &#8216;cache&#8217; as you illustrated in your linked post where within the function, eg:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> const NUM_ITERATIONS<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">1000000</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> testDynamicFunctions<span style="color: #000000;">&#40;</span>ev<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    const NUM_ITERATIONS<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>NUM_ITERATIONS<span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> beforeTime<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>I humbly and profusely apologize for the horrible misinformation prior. It is still disappointing, however the performance drop is not nearly as jarring as before!</p>
<p>Plain: 6660<br />
Local: 2335<br />
Function var: 2307</p>
<p>Private: 245<br />
Protected: 241<br />
Internal: 238<br />
Public: 247</p>
<p>this.Private: 237<br />
this.Protected: 241<br />
this.Internal: 238<br />
this.Public: 232</p>
<p>Static private: 354<br />
Static protected: 268<br />
Static internal: 271<br />
Static public: 261</p>
<p>Override protected: 236<br />
Override internal: 246<br />
Override public: 242</p>
<p>Super protected: 227<br />
Super internal: 282<br />
Super public: 294</p>
<p>Interface direct: 226<br />
Interface via interface: 276<br />
Interface via class: 222</p>
<p>Private Get: 234<br />
Protected Get: 225<br />
Internal Get: 222<br />
Public Get: 222</p>
<p>Private Set: 2489<br />
Protected Set: 5797<br />
Internal Set: 2382<br />
Public Set: 2505</p>
<p>Final Private: 244<br />
Final Protected: 252<br />
Final Internal: 288<br />
Final Public: 352</p>
<p>Final Override protected: 226<br />
Final Override internal: 223<br />
Final Override public: 224</p>
<p>I performed these tests three times. Once I saw an anomalous doubling of this.Private, but that did not occur 2/3 times. However Protected Set is consistently twice as slow as its Internal, Private and Public counterparts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-8088</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 24 Jun 2011 18:59:47 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-8088</guid>
		<description>Interesting results. It&#039;s a shame to see such poor performance. However, I have a couple of suggestions that may speed these times up:

1) Make sure you&#039;re using a release build. ActionScript typically runs 2-3x slower in debug builds.
2) A static field lookup every loop will be very expensive and greatly increase loop times overall. It&#039;s annoying to have to keep declaring NUM_ITERATIONS locally, but local variable lookup is really &lt;a href=&quot;/articles/1133&quot; rel=&quot;nofollow&quot;&gt;worth it&lt;/a&gt;.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Interesting results. It&#8217;s a shame to see such poor performance. However, I have a couple of suggestions that may speed these times up:</p>
<p>1) Make sure you&#8217;re using a release build. ActionScript typically runs 2-3x slower in debug builds.<br />
2) A static field lookup every loop will be very expensive and greatly increase loop times overall. It&#8217;s annoying to have to keep declaring NUM_ITERATIONS locally, but local variable lookup is really <a href="/articles/1133" rel="nofollow">worth it</a>.</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP Stringham</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-8087</link>
		<dc:creator>JP Stringham</dc:creator>
		<pubDate>Fri, 24 Jun 2011 18:35:09 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-8087</guid>
		<description>For the sake of interest and with all the fuss these days about Flash on iOS, I decided to execute this script on an iPhone 4. I had to make a couple modifications.

1) The NUM_ITERATIONS was made into a private static const.
2) NUM_ITERATIONS was DECREASED by an order of magnitude. Execution times were still abysmal.

Plain: 19886
Local: 16043
Function var: 16187

Private: 5584
Protected: 5622
Internal: 6017
Public: 6492

this.Private: 5524
this.Protected: 5624
this.Internal: 5780
this.Public: 5662

Static private: 5818
Static protected: 5632
Static internal: 5638
Static public: 5743

Override protected: 5856
Override internal: 5911
Override public: 5695

Super protected: 5674
Super internal: 5853
Super public: 5901

Interface direct: 5510
Interface via interface: 5550
Interface via class: 5514

Private Get: 6563
Protected Get: 6172
Internal Get: 5844
Public Get: 5644

Private Set: 16141
Protected Set: 18751
Internal Set: 16383
Public Set: 15935

Final Private: 56311
Final Protected: 56317
Final Internal: 56242
Final Public: 56032

Final Override protected: 56237
Final Override internal: 55356
Final Override public: 55609

Built for iOS from Flash Builder 4.5.1 targeting AIR 2.7. Interestingly this flies completely in the face of the optimization &#039;wisdom&#039; preached by Adobe themselves. And no, those last results aren&#039;t typos, I had to wait several minutes before I saw any results.</description>
		<content:encoded><![CDATA[<p>For the sake of interest and with all the fuss these days about Flash on iOS, I decided to execute this script on an iPhone 4. I had to make a couple modifications.</p>
<p>1) The NUM_ITERATIONS was made into a private static const.<br />
2) NUM_ITERATIONS was DECREASED by an order of magnitude. Execution times were still abysmal.</p>
<p>Plain: 19886<br />
Local: 16043<br />
Function var: 16187</p>
<p>Private: 5584<br />
Protected: 5622<br />
Internal: 6017<br />
Public: 6492</p>
<p>this.Private: 5524<br />
this.Protected: 5624<br />
this.Internal: 5780<br />
this.Public: 5662</p>
<p>Static private: 5818<br />
Static protected: 5632<br />
Static internal: 5638<br />
Static public: 5743</p>
<p>Override protected: 5856<br />
Override internal: 5911<br />
Override public: 5695</p>
<p>Super protected: 5674<br />
Super internal: 5853<br />
Super public: 5901</p>
<p>Interface direct: 5510<br />
Interface via interface: 5550<br />
Interface via class: 5514</p>
<p>Private Get: 6563<br />
Protected Get: 6172<br />
Internal Get: 5844<br />
Public Get: 5644</p>
<p>Private Set: 16141<br />
Protected Set: 18751<br />
Internal Set: 16383<br />
Public Set: 15935</p>
<p>Final Private: 56311<br />
Final Protected: 56317<br />
Final Internal: 56242<br />
Final Public: 56032</p>
<p>Final Override protected: 56237<br />
Final Override internal: 55356<br />
Final Override public: 55609</p>
<p>Built for iOS from Flash Builder 4.5.1 targeting AIR 2.7. Interestingly this flies completely in the face of the optimization &#8216;wisdom&#8217; preached by Adobe themselves. And no, those last results aren&#8217;t typos, I had to wait several minutes before I saw any results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/413/comment-page-1#comment-7298</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Sun, 05 Jun 2011 21:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=413#comment-7298</guid>
		<description>There will naturally be some &quot;wiggle&quot; in your test results. Try running the test several times and seeing how the results vary. I think the differences between access specifier (&lt;code&gt;public&lt;/code&gt;, &lt;code&gt;private&lt;/code&gt;, etc.) and &lt;code&gt;final&lt;/code&gt;/not &lt;code&gt;final&lt;/code&gt; are minor testing anomalies: they don&#039;t actually change the performance.</description>
		<content:encoded><![CDATA[<p>There will naturally be some &#8220;wiggle&#8221; in your test results. Try running the test several times and seeing how the results vary. I think the differences between access specifier (<code>public</code>, <code>private</code>, etc.) and <code>final</code>/not <code>final</code> are minor testing anomalies: they don&#8217;t actually change the performance.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

