<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>robert zubek / blog &#187; flash</title>
	<atom:link href="http://robert.zubek.net/blog/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://robert.zubek.net/blog</link>
	<description></description>
	<lastBuildDate>Thu, 01 Apr 2010 05:40:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Hey, Young Whirled!</title>
		<link>http://robert.zubek.net/blog/2008/03/25/hey-young-whirled/</link>
		<comments>http://robert.zubek.net/blog/2008/03/25/hey-young-whirled/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 20:22:23 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[three rings]]></category>
		<category><![CDATA[whirled]]></category>

		<guid isPermaLink="false">http://robert.zubek.net/blog/2008/03/25/hey-young-whirled/</guid>
		<description><![CDATA[Here&#8217;s what I&#8217;ve been working on all this time: Whirled is now in public beta! Below is a live view into my room &#8211; stop by and say hello! Launch the full version of Whirled]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s what I&#8217;ve been working on all this time: <a href="http://www.whirled.com">Whirled</a> is now in public beta!</p>
<p>Below is a live view into my room &#8211; stop by and say hello! <img src='http://robert.zubek.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.whirled.com/welcome/4/" target="_top">Launch the full version of Whirled</a></p>
]]></content:encoded>
			<wfw:commentRss>http://robert.zubek.net/blog/2008/03/25/hey-young-whirled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 bytecode performance</title>
		<link>http://robert.zubek.net/blog/2008/01/12/actionscript-3-bytecode-performance/</link>
		<comments>http://robert.zubek.net/blog/2008/01/12/actionscript-3-bytecode-performance/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 18:07:27 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://robert.zubek.net/blog/2007/09/29/actionscript-3-bytecode-performance/</guid>
		<description><![CDATA[Here are the results of a little benchmark I ran a while back, trying to figure out how expensive are the different primitive operations in Flash 9 (ie. bytecode compiled ActionScript 3). Quick note on methodology: I ran these primitive operations in a tight loop of a few million iterations, to get average runtime per iteration (subtracting out [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the results of a little benchmark I ran a while back, trying to figure out how expensive are the different primitive operations in Flash 9 (ie. bytecode compiled ActionScript 3).</p>
<p>Quick note on methodology: I ran these primitive operations in a tight loop of a few million iterations, to get average runtime per iteration (subtracting out the runtime of an empty loop, of course), and then repeated this a handful of times. I&#8217;m reporting mean numbers below, and standard deviations only when they&#8217;re unusual.</p>
<p>The raw times aren&#8217;t very important (benchmarks were done on an old Athlon 2400+ that&#8217;s living out its retirement years under my kitchen table). But the proportional differences between them can be surprising &#8211; especially the order-of-magnitude ones.</p>
<p>Now, on to some delicious results!</p>
<p><strong>Numbers</strong></p>
<p>Some obligatory numeric operation benchmarks:</p>
<blockquote><p>Signed integer addition: 6.3ns<br />
Signed integer multiplication: 13.1ns<br />
Signed integer division: 15.3ns</p>
<p>Unsigned integer addition: 9.6ns<br />
Unsigned integer multiplication: 28.3ns<br />
Unsigned integer division: 32.4ns</p>
<p>Double addition: 9.4ns<br />
Double multiplication: 7.4ns<br />
Double division: 7.1ns</p></blockquote>
<p>There&#8217;s really no reason not to use doubles for virtually all math operations; they&#8217;re much cheaper (possibly because they don&#8217;t try to do any bounds checks).</p>
<p>The one exception would be array indexing, where one really wants to guarantee that the index is an integer. Fortunately, conversions are pretty inexpensive as well:</p>
<blockquote><p>Integer -&gt; Number conversion: 7.3ns<br />
Number -&gt; integer conversion: 5.0ns</p></blockquote>
<p>Now for some math library operations:</p>
<blockquote><p>Math.sqrt: 137.9ns<br />
Math.sin: 183.3ns<br />
Math.round: 197.9ns<br />
Math.floor: 160.2ns</p></blockquote>
<p>That&#8217;s pretty good, much faster than regular function calls (see below) &#8211; probably because these are native, instead of bottoming out in bytecode like everything else. Still, a square root is on the order of about 20 times more expensive than arithmetic operations.</p>
<p><strong>Function Calls</strong></p>
<p>Speaking of which, here are the regular function calls &#8211; just the call, with no body:</p>
<blockquote><p>Function call (no arguments): 239.8ns<br />
Function call (unary): 257.6ns<br />
Function call (binary): 269.0ns</p></blockquote>
<p>Pretty standard stuff, with cost increasing (linearly?) as a function of the number of arguments. It&#8217;s more expensive than calling native functions, but not significantly higher. Still, it does put an upper limit of about 4 million function calls a second, or 100,000 calls per frame, on my test machine.</p>
<p>By the way, this was completely unexpected:</p>
<blockquote>
<p align="left">Anonymous function declaration: 11368.8ns (s = 105.3)</p>
</blockquote>
<p>Creating an instance of an anonymous function costs <em>11 microseconds?</em> Ouch. I&#8217;m a big fan of treating everything as lists of data, and map-filtering them with ad-hoc anonymous functions. But now I have to be more careful. <img src='http://robert.zubek.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Arrays</strong></p>
<p>For array access, I&#8217;ve only checked access of a single array element, many times over. Some numbers:</p>
<blockquote><p>Writing from variable to array: 69.0ns, s = 1.9<br />
Reading from array to variable: 106.3ns, s = 105.5<br />
Reading from object with integer keys: 72.0ns, s = 1.9<br />
Reading from object with string keys: 242.8ns, s = 1.8</p></blockquote>
<p>First, I thought it was interesting that an object with integer keys is just as fast as an array with integer keys, suggesting a shared underlying implementation. An object with string keys is slower, however.</p>
<p>Two, the array reading measurement is not only pretty high, it also has a very high standard deviation, as if the measurements included a few really expensive outliers. Am I running into intermittent delays when accessing array data; perhaps cache stalls?</p>
<p>Finally, some results trying to iterate over a large array:</p>
<blockquote><p>Iteration over array using &#8216;for each&#8217; special syntax: 8576.8ns, s = 2.4<br />
Iteration over array using int: 20483.5ns, s = 4.6<br />
Iteration over array using uint: 19665.3ns, s = 2.8<br />
Iteration over array using forEach: 31416.8ns, s = 47.7</p></blockquote>
<p>I&#8217;m not susprised that code inside a for loop is faster than code inside a function called via forEach. What I am surprised about, is that the &#8220;for each ( &#8230; )&#8221; special form is <em>much </em>faster than the standard &#8220;for ( ; ; )&#8221; iteration with array lookup. That&#8217;s not what you&#8217;d expect in a language like C; I&#8217;m curious what&#8217;s going on under the hood.</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.zubek.net/blog/2008/01/12/actionscript-3-bytecode-performance/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
