<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4014992927765785484</id><updated>2012-02-16T20:30:37.024-08:00</updated><title type='text'>DigiDood</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://digidood.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4014992927765785484/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://digidood.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alan</name><uri>http://www.blogger.com/profile/08141801850500794280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4014992927765785484.post-484367196643205692</id><published>2007-03-20T21:47:00.000-07:00</published><updated>2007-03-20T22:35:55.264-07:00</updated><title type='text'>Mii and Apollo</title><content type='html'>This is the first step at creating something interesting with &lt;a href="http://labs.adobe.com/wiki/index.php/Apollo"&gt;Apollo &lt;/a&gt;and Mii binary files. Others have been working on some cool apps including the &lt;a href="http://miieditor.com/"&gt;MiiEditor &lt;/a&gt;and &lt;a href="http://www.miimall.com/"&gt;MiiMall&lt;/a&gt;, etc so you might ask.. why are you doing this?.. Like &lt;a href="http://www.nomadland.com/images/KS_SHC_1.jpg"&gt;Michael Hedges&lt;/a&gt; said, "&lt;a href="http://www.youtube.com/watch?v=h0Tb2BnCnrY"&gt;Because it's there&lt;/a&gt;"!&lt;br /&gt;&lt;br /&gt;Actually there was a discussion the other day about integrating the Wii with online marketing and of course the idea came up of uploading and sharing your Mii character, so I thought it would be a great way to learn &lt;a href="http://labs.adobe.com/wiki/index.php/Apollo"&gt;Apollo &lt;/a&gt;and do something fun at the same time.&lt;br /&gt;&lt;br /&gt;Turns out, there's really nothing too &lt;a href="http://labs.adobe.com/wiki/index.php/Apollo"&gt;Apolloish &lt;/a&gt;about this app other than reading in a file but you can imagine all the possibilities for it... Well I can't yet, so help me figure out how to use this ;)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The first step&lt;/strong&gt; is to simply read in the binary file into some useful data structure so we can draw the character. Thanks to some help I got with bit masks and shifting, I got it working last night. My MiiParser takes a ByteArray and goes to work sorting out all the bits and bytes.&lt;br /&gt;&lt;br /&gt;If you are interested in helping me work on this, &lt;strong&gt;let me know&lt;/strong&gt;. I need a flash artist to create all the pieces so I can put bits to pixels. It would also be great to build a generic parser and a C-like struct in AS3 in order to do things more abstractly ( is that a word? ) like other languages have done for years.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://www.mindspring.com/~digidood/mii/MIIandAPOLLO.zip"&gt;get the code here&lt;/a&gt;. It was built with Flex Builder and &lt;a href="http://labs.adobe.com/wiki/index.php/Apollo"&gt;Apollo &lt;/a&gt;although there's nothing flexy or apolloish about it really.... yet.&lt;br /&gt;&lt;br /&gt;Also you can see the &lt;a href="http://wiibrew.org/index.php?title=Wiimote/Mii_Data"&gt;Mii data format &lt;/a&gt;here, another &lt;a href="http://miieditor.com/"&gt;MiiEditor &lt;/a&gt;here and definitely check out the &lt;a href="http://www.miimall.com/"&gt;MiiMall&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4014992927765785484-484367196643205692?l=digidood.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digidood.blogspot.com/feeds/484367196643205692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4014992927765785484&amp;postID=484367196643205692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4014992927765785484/posts/default/484367196643205692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4014992927765785484/posts/default/484367196643205692'/><link rel='alternate' type='text/html' href='http://digidood.blogspot.com/2007/03/mii-and-apollo.html' title='Mii and Apollo'/><author><name>Alan</name><uri>http://www.blogger.com/profile/08141801850500794280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4014992927765785484.post-1093211445988202757</id><published>2007-03-15T05:18:00.000-07:00</published><updated>2007-03-20T22:31:24.882-07:00</updated><title type='text'>Array optimizations for AS3/AS2</title><content type='html'>&lt;a href="http://blog.deconcept.com/"&gt;Geoff &lt;/a&gt;sent out a great link for &lt;a href="http://www.peachpit.com/articles/article.asp?p=31567&amp;seqNum=1"&gt;optimizing javascript code &lt;/a&gt;and I decided to run some tests with &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;actionscript&lt;/span&gt; related to looping over arrays using ideas from the article. These tests produced some interesting results.&lt;br /&gt;&lt;br /&gt;I ran several tests doing incremental loops and reversed loops against using "flipped" versions.&lt;br /&gt;&lt;br /&gt;Flipped just means this:&lt;br /&gt;&lt;br /&gt;var i:Number = array.length - 1;&lt;br /&gt;do {&lt;br /&gt;// something&lt;br /&gt;} while( i--);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The obvious stuff first:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. AS3 is &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;waaay&lt;/span&gt; faster than AS2. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;Yay&lt;/span&gt;, we already knew that ;)&lt;br /&gt;2. All the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_3"&gt;people&lt;/span&gt; that told you to declare the length outside the loop were right.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Now for the interesting stuff:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Reversing the loop is faster in all cases.&lt;br /&gt;2. In AS3, using a standard reversed loop is faster than using the flipped version.&lt;br /&gt;3. In AS2, using the flipped reverse version is faster than using the normal reversed version.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Now for something unexpected:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Declaring a re-used variable inside the loop was actually faster than declaring it outside the loop. Dunno bout that one, seemed counter intuitive to me. Will explore further.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;When to use what:&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;1. It depends as always on what the inner loop is doing ;)&lt;br /&gt;2. Run tests and implement the method that is faster for your implementation. Cmon, it doesn't take that long to do a couple tests and could dramatically improve performance depending on the situation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Some helpful utils:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;FDT TEMPLATE FOR REVERSE LOOP&lt;br /&gt;var length:Number = ${array}.length - 1;&lt;br /&gt;for (var ${index} : Number = length; ${index} &gt;= 0; ${index}--)&lt;br /&gt;{ ${cursor}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;FDT&lt;/span&gt; TEMPLATE FOR REVERSE FLIPPED LOOP&lt;br /&gt;var ${index}:Number = ${array}.length - 1;&lt;br /&gt;do {&lt;br /&gt;${cursor}&lt;br /&gt;} while ( ${index}-- );&lt;br /&gt;&lt;br /&gt;------------------------------------------------&lt;br /&gt;&lt;br /&gt;Here's what I did. I setup four methods that basically loop through an array of integers and adds them up. Each method just changed slightly.&lt;br /&gt;&lt;br /&gt;1. Normal forward loop without declaring the length outside the loop ( bad )&lt;br /&gt;&lt;br /&gt;public function testNormalLoop1(array:Array) :Void {&lt;br /&gt;var startTime:Number = (new Date()).getTime();&lt;br /&gt;var sum:Number = 0;&lt;br /&gt;for( var i:Number = 0; i &lt; array.length; i++ ) {&lt;br /&gt;var value:Number = array[i];&lt;br /&gt;sum+= value;&lt;br /&gt;}&lt;br /&gt;var elapsedTime:Number = (new Date()).getTime() - startTime;&lt;br /&gt;trace("testNormalLoop1() " + elapsedTime);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Same as #1 but declare length outside the loop&lt;br /&gt;3. Same as #2 but declare var value:Number; outside the loop&lt;br /&gt;4. Same as #3 but get rid of value altogether and just say sum+= array[i];&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;5-8: Same as 1-4 but reverse the loop&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;9-12: Same as 1-4 but use the flipped version. 10-12 calcuate the length outside the loop.&lt;br /&gt;&lt;br /&gt;public function testFlippedLoop1(array:Array) :Void {&lt;br /&gt;var startTime:Number = (new Date()).getTime();&lt;br /&gt;var sum:Number = 0;&lt;br /&gt;var i:Number = 0;&lt;br /&gt;do {&lt;br /&gt;i++;&lt;br /&gt;var value:Number = array[i];&lt;br /&gt;sum+= value;&lt;br /&gt;} while ( i &lt; array.length );&lt;br /&gt;var elapsedTime:Number = (new Date()).getTime() - startTime;&lt;br /&gt;trace("testFlippedLoop1() " + elapsedTime);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;13-16: Same as 9-12 but reverse the loop.&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;17-20: Same as 13-16 but decrement in the while section.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public function testAltFlippedReversedLoop1(array:Array) :Void {&lt;br /&gt;var startTime:Number = (new Date()).getTime();&lt;br /&gt;var sum:Number = 0;&lt;br /&gt;var i:Number = array.length -1;&lt;br /&gt;do {&lt;br /&gt;var value:Number = array[i];&lt;br /&gt;sum+= value;&lt;br /&gt;} while (i-- );&lt;br /&gt;var elapsedTime:Number = (new Date()).getTime() - startTime;&lt;br /&gt;trace("testAltFlippedReversedLoop1() " + elapsedTime);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;My Results:&lt;br /&gt;&lt;br /&gt;Testing array with length: 1000000&lt;br /&gt;-----------------------------------------------&lt;br /&gt;AS3&lt;br /&gt;----------------------------------------------&lt;br /&gt;testNormalLoop1() 313&lt;br /&gt;testNormalLoop2() 219&lt;br /&gt;testNormalLoop3() 218&lt;br /&gt;testNormalLoop4() 438&lt;br /&gt;testNormalReversedLoop1() 219&lt;br /&gt;testNormalReversedLoop2() 203&lt;br /&gt;testNormalReversedLoop3() 203&lt;br /&gt;testNormalReversedLoop4() 406&lt;br /&gt;testFlippedLoop1() 781&lt;br /&gt;testFlippedLoop2() 563&lt;br /&gt;testFlippedLoop3() 265&lt;br /&gt;testFlippedLoop4() 547&lt;br /&gt;testFlippedReversedLoop1() 609&lt;br /&gt;testFlippedReversedLoop2() 594&lt;br /&gt;testFlippedReversedLoop3() 250&lt;br /&gt;testFlippedReversedLoop4() 562&lt;br /&gt;testAltFlippedReversedLoop1() 547&lt;br /&gt;testAltFlippedReversedLoop2() 547&lt;br /&gt;testAltFlippedReversedLoop3() 219&lt;br /&gt;testAltFlippedReversedLoop4() 453&lt;br /&gt;&lt;br /&gt;-----------------------------------------------&lt;br /&gt;AS2&lt;br /&gt;-----------------------------------------------&lt;br /&gt;testNormalLoop1() 1390&lt;br /&gt;testNormalLoop2() 1172&lt;br /&gt;testNormalLoop3() 1188&lt;br /&gt;testNormalLoop4() 1265&lt;br /&gt;testNormalReversedLoop1() 1266&lt;br /&gt;testNormalReversedLoop2() 1250&lt;br /&gt;testNormalReversedLoop3() 1265&lt;br /&gt;testNormalReversedLoop4() 1297&lt;br /&gt;testFlippedLoop1() 1328&lt;br /&gt;testFlippedLoop2() 1109&lt;br /&gt;testFlippedLoop3() 1125&lt;br /&gt;testFlippedLoop4() 1219&lt;br /&gt;testFlippedReversedLoop1() 1359&lt;br /&gt;testFlippedReversedLoop2() 1188&lt;br /&gt;testFlippedReversedLoop3() 1187&lt;br /&gt;testFlippedReversedLoop4() 1266&lt;br /&gt;testAltFlippedReversedLoop1() 1063&lt;br /&gt;testAltFlippedReversedLoop2() 1062&lt;br /&gt;testAltFlippedReversedLoop3() 1063&lt;br /&gt;testAltFlippedReversedLoop4() 1140&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4014992927765785484-1093211445988202757?l=digidood.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digidood.blogspot.com/feeds/1093211445988202757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4014992927765785484&amp;postID=1093211445988202757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4014992927765785484/posts/default/1093211445988202757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4014992927765785484/posts/default/1093211445988202757'/><link rel='alternate' type='text/html' href='http://digidood.blogspot.com/2006/08/beta-test.html' title='Array optimizations for AS3/AS2'/><author><name>Alan</name><uri>http://www.blogger.com/profile/08141801850500794280</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
