<?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>Randomize Everything &#187; performance gains</title>
	<atom:link href="http://www.bartclaessens.com/tag/performance-gains/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bartclaessens.com</link>
	<description>And create the perfect world</description>
	<lastBuildDate>Sat, 17 Jul 2010 11:57:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Quicktip #5: int is faster than uint</title>
		<link>http://www.bartclaessens.com/2009/06/quicktip-5-int-is-faster-than-uint/</link>
		<comments>http://www.bartclaessens.com/2009/06/quicktip-5-int-is-faster-than-uint/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 08:35:59 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[QuickTips]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[actionscript performance]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[Number]]></category>
		<category><![CDATA[performance gains]]></category>
		<category><![CDATA[uint]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=177</guid>
		<description><![CDATA[The past few weeks I&#8217;ve been programming a scheduling component in Flash which has to be extremely performant. Every small adaption in my code that could help with limiting the processing needs is a good adaption. Today I stumbled upon a post of Grant Skinner in which he explains that using a uint is slower [...]]]></description>
			<content:encoded><![CDATA[<p>The past few weeks I&#8217;ve been programming a scheduling component in Flash which has to be extremely performant. Every small adaption in my code that could help with limiting the processing needs is a good adaption. Today I stumbled upon a post of Grant Skinner in which he explains that using a uint is slower than a normal int. The uint&#8217;s can get five times slower than using a normal int.</p>
<p><span id="more-177"></span></p>
<p>So, what about the Number type? Well, I thought the Number type was a very slow type compared to the new int and uint but that also didn&#8217;t seem to be right!</p>
<blockquote><p>
Sho just posted a really interested article on why he won&#8217;t be using the int data type very frequently in ActionScript 3. Up until reading it, I had believed that as in other languages, there were large performance benefits to using ints and uints appropriately in AS3. Turns out that isn&#8217;t the case.</p>
<p>I did some quick testing on this, which confirm Sho&#8217;s assertion that int is only slightly faster than Number in ideal circumstances, but the results from uint were much more surprising.
</p></blockquote>
<p>Read the complete post here: <a href="http://www.gskinner.com/blog/archives/2006/06/types_in_as3_in.html">gskinner.com</a></p>
<div class="shr-publisher-177"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2009/06/quicktip-5-int-is-faster-than-uint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some ActionScript optimization tricks and good practises</title>
		<link>http://www.bartclaessens.com/2008/09/some-actionscript-optimization-tricks-and-good-practises/</link>
		<comments>http://www.bartclaessens.com/2008/09/some-actionscript-optimization-tricks-and-good-practises/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 21:46:31 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[actionscript performance]]></category>
		<category><![CDATA[bitmap performance]]></category>
		<category><![CDATA[bitmapdata performance]]></category>
		<category><![CDATA[destroy function]]></category>
		<category><![CDATA[large images]]></category>
		<category><![CDATA[memory management]]></category>
		<category><![CDATA[performance gains]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=30</guid>
		<description><![CDATA[The last few months I have been busy integrating Flash swf files into bigger (mostly Flex) projects. Because Flex websites might hog the memory due to large amounts of graphical elements and sometimes enormous huge amount of dynamic content, I had to keep an eye out for performance drops. There have been a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>The last few months I have been busy integrating Flash swf files into bigger (mostly Flex) projects. Because Flex websites might hog the memory due to large amounts of graphical elements and sometimes enormous huge amount of dynamic content, I had to keep an eye out for performance drops.</p>
<p>There have been a lot of optimization tricks for ActionScript 3, mine listed here will probably already be somewhere on one or another guru&#8217;s blog. But I&#8217;d like to list them again because I think there is a need to educate beginning (and sometimes advanced) ActionScript developers about the different performance capabilities. Please mind that this is NOT a complete list in any way. These optimizations are the ones I had to use the most lately.</p>
<p><span id="more-30"></span></p>
<p><strong>Trick 1:</strong></p>
<p>Always create a destroy() function on your sprites/movieclips/shapes when they have a custom class applied to them or when they are just standalone custom classes.<br />
The destroy function should be responsible to do the following:</p>
<ul>
<li>clear ANY listener that was used in the custom class, use hasEventListener() to check if there is a listener added in the first place!</li>
<li>remove the children of the custom class</li>
<li>set the removed child to null to clear the reference: myChild = null;</li>
</ul>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
* Clean up the current circle image the gain back performance.
*/</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> cleanUpCurrentCircleImage<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    currentCircleImage.destroy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>currentCircleImage.<span style="color: #004993;">hasEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_OUT<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> currentCircleImage.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_OUT, cleanUpCurrentCircleImage<span style="color: #000000;">&#41;</span>;
    <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>currentCircleImage.<span style="color: #004993;">hasEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_IN<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> currentCircleImage.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_IN, timeOutTillNextImage<span style="color: #000000;">&#41;</span>;
&nbsp;
    <span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>currentCircleImage<span style="color: #000000;">&#41;</span>;
    currentCircleImage = <span style="color: #0033ff; font-weight: bold;">null</span>;
&nbsp;
    showImage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Trick 2:</strong></p>
<p>A useful trick when you have a lot of BitmapData. You have to know that a lot of BitmapData just keeps sitting in the memory although you removed the container Bitmap. Don&#8217;t ask me why the Flash Player does this but is very annoying as my colleagues at BoulevArt noticed while adding an image of 10 000 by 3000 pixels to the stage. They sliced up the image in different images and loaded the images that were needed at runtime. But they also had to delete the images again when they were not necessary anymore.</p>
<p>Solution: the BitmapData class has a very usefull dispose() function you can use to get rid of the real pixel data.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> myBitmap<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
myBitmap.<span style="color: #004993;">bitmapData</span>.<span style="color: #004993;">dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p><strong>Trick 3:</strong></p>
<p>Use a memory monitoring class so that you can keep an eye out on the -real- memory usage of your Flash. A good, but hard to find class is: ActiveGraph created by rezmason.</p>
<p>I added the class here to make it easy for you. Don&#8217;t forget to thank rezmason for the great class :p.</p>
<p><a href='http://www.bartclaessens.com/wp-content/uploads/2009/05/activegraph.zip'>ActiveGraph Class</a></p>
<p>That&#8217;s it for now. Not that much hu? Well, this is certainly not the end, keep an eye out on my blog because I feel we have to do a lot more performance tweaking :p</p>
<div class="shr-publisher-30"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2008/09/some-actionscript-optimization-tricks-and-good-practises/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

