<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.1" -->
<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/"
	>

<channel>
	<title>jlGauthier.</title>
	<link>http://jlgauthier.com/blog</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sun, 06 Feb 2011 05:57:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<item>
		<title>Scratch Objects and performance.</title>
		<link>http://jlgauthier.com/blog/?p=10</link>
		<comments>http://jlgauthier.com/blog/?p=10#comments</comments>
		<pubDate>Thu, 14 Feb 2008 09:40:18 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=10</guid>
		<description><![CDATA[So Actionscript 3 is fast&#8230;. er than actionscript 2. But performance is still a big bottleneck. One well known fact is object creation is slow. Adobe knows this and is addressing it
@see Tamarin Bugzilla
But I was crunching some code tonight and was startled at just how slow it really is.
Take The following function :
	/**
	 * [...]]]></description>
			<content:encoded><![CDATA[<p>So Actionscript 3 is fast&#8230;. er than actionscript 2. But performance is still a big bottleneck. One well known fact is object creation is slow. Adobe knows this and is addressing it<br />
@see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=412662">Tamarin Bugzilla</a></p>
<p>But I was crunching some code tonight and was startled at just how slow it really is.<br />
Take The following function :</p>
<blockquote><p><code>	/**<br />
	 * rotates a point by this quaternion.<br />
	 */<br />
	public function rotatePoint(p : Point3d) : void {<br />
		 &nbsp;&nbsp;&nbsp;// copy of origin p<br />
		 &nbsp;&nbsp;&nbsp;var _:Point3d = new Point3d();<br />
		 &nbsp;&nbsp;&nbsp;_.x=p.x*2, _.y=p.y*2, _.z=p.z*2;</p>
<p>	  	 &nbsp;&nbsp;&nbsp;p.x -= (y*y + z*z)*_.x - (x*y - z*w)*_.y - (x*z + y*w)*_.z;<br />
	  	 &nbsp;&nbsp;&nbsp;p.y += (x*y + z*w)*_.x - (x*x + z*z)*_.y - (x*w - y*z)*_.z;<br />
	  	 &nbsp;&nbsp;&nbsp;p.z += (x*z - y*w)*_.x  + (x*w + y*z)*_.y - (x*x + y*y)*_.z;<br />
	}</code></p></blockquote>
<p>But if we change this apparently math heavy function to use a scratch object instead of creating a new instance of Point3d each call &#8230;</p>
<blockquote><p><code>	/**<br />
	 * rotates a point by this quaternion.<br />
	 */<br />
	public function rotatePoint(p : Point3d) : void {<br />
		 &nbsp;&nbsp;&nbsp;// '_' is a scratch Point3d private to this instance<br />
		 &nbsp;&nbsp;&nbsp;_.x=p.x*2, _.y=p.y*2, _.z=p.z*2;</p>
<p>	  	 &nbsp;&nbsp;&nbsp;p.x -= (y*y + z*z)*_.x - (x*y - z*w)*_.y - (x*z + y*w)*_.z;<br />
	  	 &nbsp;&nbsp;&nbsp;p.y += (x*y + z*w)*_.x - (x*x + z*z)*_.y - (x*w - y*z)*_.z;<br />
	  	 &nbsp;&nbsp;&nbsp;p.z += (x*z - y*w)*_.x + (x*w + y*z)*_.y - (x*x + y*y)*_.z;<br />
	}</p>
<p>	// scratch Point3d for quick private use.<br />
	// maintains no significance<br />
	private static const _ : Point3d = new Point3d();</code></p></blockquote>
<p>rotatePoint now executes a stunning 5(<strong>FIVE!</strong>) times faster.</p>
<p><em>and since we&#8217;re talking performance&#8230;</em><br />
Static variables are <em>usually</em> slow<br />
@see <a href="http://bugs.adobe.com/jira/browse/ASC-2595">Adobe Jira</a><br />
But since this scratch object is local there is no HT lookup cost. We&#8217;re simply creating one scratch Point3d to be used by all instances of the class. Call it a dirty trick, but we have one thread and its fair game.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=10</wfw:commentRss>
		</item>
		<item>
		<title>Leaving Beantown.</title>
		<link>http://jlgauthier.com/blog/?p=9</link>
		<comments>http://jlgauthier.com/blog/?p=9#comments</comments>
		<pubDate>Sat, 09 Feb 2008 20:53:07 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=9</guid>
		<description><![CDATA[Big changes. Recently I was given an opportunity to go to San Diego and make games with Areae. I have a lot of friends and family in the Boston area and I know I&#8217;ll miss them a lot while I&#8217;m tanning my irish skin on the pacific coast beaches in February. 
But besides the grumpy [...]]]></description>
			<content:encoded><![CDATA[<p>Big changes. Recently I was given an opportunity to go to San Diego and make games with <a href="http://www.areae.net/">Areae</a>. I have a lot of friends and family in the Boston area and I know I&#8217;ll miss them a lot while I&#8217;m tanning my irish skin on the pacific coast beaches in February. </p>
<p>But besides the grumpy people, nasty cold, maze-like streets I&#8217;m also going to miss the <a href="http://bfpug.com">Flash community of Boston</a>. I hope you guys dont quiesce in my absence, because you can rate a city <a href="http://bit101.tumblr.com/post/25756473">by</a> how <a href="http://deitte.com/">many</a> programmer&#8217;s <a href="http://blog.pixelconsumption.com/">drink</a> Kamikaze <a href="http://www.brightworks.com/flex_ability/">shots</a> on <a href="http://www.forestandthetrees.com/">a</a> work <a href="http://jlgauthier.com/blog/">night</a>. See you guys at Flash on Tap and the Ugly Sweater Party.</p>
<p>Leaving my current job at <a href="http://www.visual-io.com">Visual-io</a> is a tough one too. Visual-io is a great place to work <a href="http://www.forestandthetrees.com/">Doug</a>, John, Brett, my duck and all the dinosaurs have been great developers to work with. P.S. Duck is coming  with me to San Diego. If you timebox it with some HLD and LLD I&#8217;m sure you can frob up another one in a few cycles.</p>
<p>Man, I would write on but I am tearing up. You rock Boston.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
		<item>
		<title>Editor version 0.2</title>
		<link>http://jlgauthier.com/blog/?p=8</link>
		<comments>http://jlgauthier.com/blog/?p=8#comments</comments>
		<pubDate>Fri, 08 Feb 2008 09:18:58 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[3d Figures]]></category>

		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=8</guid>
		<description><![CDATA[http://www.jlgauthier.com/blogSup/stick/edit2/bin-release/StickEdit1.html
Moving along. I was hoping things would go fast tonight but calculating where a vertex should go to based on the x,y of a view port proved to be a lot of code.
Rendering a point in 3d means

place the point in scene space (points are stored initially in figure space)
translate its position to camera space [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jlgauthier.com/blogSup/stick/edit2/bin-release/StickEdit1.html">http://www.jlgauthier.com/blogSup/stick/edit2/bin-release/StickEdit1.html</a></p>
<p>Moving along. I was hoping things would go fast tonight but calculating where a vertex should go to based on the x,y of a view port proved to be a lot of code.</p>
<p>Rendering a point in 3d means</p>
<ol>
<li>place the point in scene space (points are stored initially in figure space)</li>
<li>translate its position to camera space (relitive to the eye of the camera)</li>
<li>rotate its position relative to the eye of the camera&#8217;s view direction (the angle between the camera eye and the camera target)</li>
<li>translate the position again into view space (if your render region is 400 by 400 you need to move things 200 pixels right and down)</li>
<li>scale the final xy coordinates based on the z axis and your perspective multiplier</li>
</ol>
<p>And that is what gets rendered in the view port&#8230; so moving a point in a view port means going through all of those steps backwards to calculate what your really doing to the vertex. Talk about fun.</p>
<p>The next step is easy, allow export and import of figures. But after that its going to get hard again because animation means adding state to the figures, which could lead to some refactoring on the rendering side of things and a lot more math.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=8</wfw:commentRss>
		</item>
		<item>
		<title>Editing the people.</title>
		<link>http://jlgauthier.com/blog/?p=7</link>
		<comments>http://jlgauthier.com/blog/?p=7#comments</comments>
		<pubDate>Wed, 06 Feb 2008 10:15:03 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[3d Figures]]></category>

		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=7</guid>
		<description><![CDATA[Another free night&#8230; kinda and started working on an editor. It&#8217;s rather useless thus far&#8230; but it looks cool and has a lot of buttons that do things 

See it.
I decided it would be more fun to do animation than texturing for a few reasons.

Paper vision already does kick ass texturing.
The figures have no flat [...]]]></description>
			<content:encoded><![CDATA[<p>Another free night&#8230; kinda and started working on an editor. It&#8217;s rather useless thus far&#8230; but it looks cool and has a lot of buttons that do things <img src='http://jlgauthier.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<img src="http://www.jlgauthier.com/blogSup/stick/editorShot.gif" alt="editor" /><br />
<a href="http://www.jlgauthier.com/blogSup/stick/edit/bin-release/StickEdit1.html">See it.</a></p>
<p>I decided it would be more fun to do animation than texturing for a few reasons.</p>
<ol>
<li><a href="http://www.papervision.org">Paper vision</a> already does kick ass texturing.</li>
<li>The figures have no flat faces so texturing well means using displacement maps all over the place.</li>
<li>My estimation is that effective texturing will run at least 2 times slower</li>
</ol>
<p>So animation is going to be way more fun anyway.. The editor shell came along pretty quick, hopefully Thrs I&#8217;ll have some time to play with it and get dragable vertexes, and parent / child rotation. </p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=7</wfw:commentRss>
		</item>
		<item>
		<title>3D stick people.</title>
		<link>http://jlgauthier.com/blog/?p=6</link>
		<comments>http://jlgauthier.com/blog/?p=6#comments</comments>
		<pubDate>Thu, 31 Jan 2008 09:24:06 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[3d Figures]]></category>

		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=6</guid>
		<description><![CDATA[
Take them for a spin
I&#8217;ve wanted to build this for a long time, luckily I&#8217;ve had trouble sleeping this week.
The engine defines figures with vertexes in 3d space, then draws lines between them instead of using triangular faces.  scaling the vetexes makes the people tall, thickening the lines makes them fat. The hope is [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jlgauthier.com/blogSup/stick/flashstickpeople.gif" alt="people" /><br />
<a href="http://www.jlgauthier.com/blogSup/stick/bin-release/stickman.html">Take them for a spin</a></p>
<p>I&#8217;ve wanted to build this for a long time, luckily I&#8217;ve had trouble sleeping this week.<br />
The engine defines figures with vertexes in 3d space, then draws lines between them instead of using triangular faces.  scaling the vetexes makes the people tall, thickening the lines makes them fat. The hope is to get some texturing on them and do some animations, but who knows. Cool concept I think.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=6</wfw:commentRss>
		</item>
		<item>
		<title>SubSpace in flash</title>
		<link>http://jlgauthier.com/blog/?p=5</link>
		<comments>http://jlgauthier.com/blog/?p=5#comments</comments>
		<pubDate>Mon, 07 Jan 2008 07:42:33 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[Flash Games]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=5</guid>
		<description><![CDATA[I&#8217;ve been working on simple Subspace engine in flash. It&#8217;s just getting to the point where it is fun to fly in, so I thought it was time to show it off.
Click the image to play

The server is written in java and uses tcp/ip (an ill-advised protocol for multiplayer games) so response time is not [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on simple <a href="http://en.wikipedia.org/wiki/SubSpace_%28computer_game%29">Subspace</a> engine in flash. It&#8217;s just getting to the point where it is fun to fly in, so I thought it was time to show it off.</p>
<p><em>Click the image to play</em><br />
<a href="http://www.jlgauthier.com/blogSup/shipGame/bin/ShipGame.html"><img src="http://www.jlgauthier.com/blogSup/shipGame/shipgame.gif" alt="Click to play" /></a><br />
The server is written in java and uses tcp/ip (an ill-advised protocol for multiplayer games) so response time is not great but it is handling ok so far. Whats exciting is Flash 10 may have UDP support so games like this may start appearing on flash game web-sites, I&#8217;m still looking for proof of this, although I have heard it second hand&#8230; whats that worth?</p>
<p>I&#8217;m not sure if I will be working more on this engine or not, this was more of an educational project for me, but who knows. Let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=5</wfw:commentRss>
		</item>
		<item>
		<title>A Better Look at uint int and Number Performance Data.</title>
		<link>http://jlgauthier.com/blog/?p=3</link>
		<comments>http://jlgauthier.com/blog/?p=3#comments</comments>
		<pubDate>Sun, 11 Nov 2007 01:44:23 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=3</guid>
		<description><![CDATA[I&#8217;ve written a benchmark swf to time several operations and conversions across all three numeric types. Using the methodology described in my previous post, the test suite compares the time cost of each opperation to the time cost of a single function call. Using function-time as a unit hopefuly minimizes proccessor speed as a factor.
Run [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a benchmark swf to time several operations and conversions across all three numeric types. Using the methodology described in my previous post, the test suite compares the time cost of each opperation to the time cost of a single function call. Using function-time as a unit hopefuly minimizes proccessor speed as a factor.</p>
<p><a href="http://www.jlgauthier.com/blogSup/performance/NumberTypes.html"><strong>Run the test for yourself (click here)</strong></a><br />
Please run the swf and comment to this post with your own results (be sure to select all). I&#8217;m especially intrested in result sets from varying opperating systems. When I collect enough data I&#8217;ll post again with some better analysis.</p>
<p><a href="http://www.jlgauthier.com/blogSup/performance/srcview/">source code</a></p>
<p><code>Debug Development Player<br />
[Adobe Windows, Windows XP]<br />
[ActiveX, WIN 9,0,28,0]<br />
function call time: 929<br />
Array[Index]<br />
uint: 0.079 int: 0.134 number: 0.545<br />
Addition += uint<br />
uint: 0.275 int: 0.276 number: 0.381<br />
Addition += int<br />
uint: 0.029 int: 0.027 number: 0.073<br />
Addition += Number<br />
uint: 0.565 int: 0.242 number: 0.079<br />
subtraction -= uint<br />
uint: 0.920 int: 0.587 number: 0.381<br />
subtraction -= int<br />
uint: 0.561 int: 0.031 number: 0.074<br />
subtraction -= Number<br />
uint: 0.565 int: 0.241 number: 0.079<br />
Addition + 5<br />
uint: 0.031 int: 0.032 number: 0.073<br />
Subtraction - 5<br />
uint: 0.522 int: 0.035 number: 0.071<br />
Bin&#038;ry Op<br />
uint: 0.024 int: 0.025 number: 0.289<br />
M%dulus<br />
uint: 1.321 int: 0.867 number: 0.905<br />
Di/ision<br />
uint: 0.627 int: 0.193 number: 0.411<br />
Multiplication * 5<br />
uint: 0.569 int: 0.151 number: 0.416<br />
Multiplication * .5<br />
uint: 0.548 int: 0.248 number: 0.081<br />
Assingment=uint<br />
uint: 0.025 int: 0.025 number: 0.322<br />
Assingment=int<br />
uint: 0.024 int: 0.027 number: 0.029<br />
Assingment=Number 56<br />
uint: 0.103 int: 0.103 number: 0.022<br />
Assingment=Number 5.6<br />
uint: 0.103 int: 0.101 number: 0.022<br />
Compare==uint<br />
uint: 0.004 int: 0.372 number: 0.347<br />
Compare==int<br />
uint: 0.350 int: 0.004 number: 0.020<br />
Compare==Number<br />
uint: 0.344 int: 0.019 number: 0.012<br />
uint(convert)<br />
uint: 0.025 int: 0.024 number: 0.104<br />
int(convert)<br />
uint: 0.023 int: 0.025 number: 0.105<br />
Number(convert)<br />
uint: 0.324 int: 0.031 number: 0.025<br />
For (<loop++)<br />
uint: 0.027 int: 0.027 number: 0.443<br />
while (loop--)<br />
uint: 0.442 int: 0.034 number: 0.132<br />
Complete.</code></p>
<p>After running this test at home and at work I&#8217;m so far drawing these conclusions:</p>
<p>Generally mixing types is slow, manually converting types is faster than relying on coersion.<br />
Number performs best in opperations where floats might occur.<br />
uint performs poorly with most arithmetic but best with indexing and binary ops.<br />
int is the most versatile and forgiving. For many opperations inline conversion of uints to int, or Numbers to int will improve performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=3</wfw:commentRss>
		</item>
		<item>
		<title>Two Tips for Benchmarking.</title>
		<link>http://jlgauthier.com/blog/?p=4</link>
		<comments>http://jlgauthier.com/blog/?p=4#comments</comments>
		<pubDate>Sun, 11 Nov 2007 00:10:32 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://jlgauthier.com/blog/?p=4</guid>
		<description><![CDATA[In anticipation of throwing a ton of benchmark data at you, I am going to run through two tips on benchmarking in Actionscript. The purpose is to explain my techniques, give credibility to my own benchmark data, and to help point out some not-so obvios pitfalls.
Avoid the debug compile
The debug compile in Flex-builder is severely [...]]]></description>
			<content:encoded><![CDATA[<p>In anticipation of throwing a ton of benchmark data at you, I am going to run through two tips on benchmarking in Actionscript. The purpose is to explain my techniques, give credibility to my own benchmark data, and to help point out some not-so obvios pitfalls.</p>
<p><strong>Avoid the debug compile</strong><br />
The debug compile in Flex-builder is severely tainted with debug code. Optimizations that improve performance in a debug compile may not improve performance in a release compile. Depending on your version of flexbuilder you may need to publish a release version to compile with out debug code.</p>
<p><strong>Isolate what your testing</strong><br />
This is a no brainer, but it needs to be said. If you want to know how long it takes to perform an opperation, but the opperation is too fast to measure in milliseconds its obvios to place that opperation in a for loop. The catch here is you must subtract the time of running the foor loop or you will taint your results.</p>
<p>example :<br />
<code>var i:uint=0, t2:int=0, t1:int=0, t0:int=getTimer();<br />
for(i=0;i<_testScale; i++){<br />
}<br />
t1=getTimer();<br />
for(i=0;i<_testScale;i++){<br />
	__test1();<br />
}<br />
t2=getTimer();<br />
_out('function call time: '+((t2-t1)-(t1-t0))+'\n');</code></p>
<p>This is especially important for granular timing as you will see in my next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=4</wfw:commentRss>
		</item>
		<item>
		<title>OK a blog.</title>
		<link>http://jlgauthier.com/blog/?p=1</link>
		<comments>http://jlgauthier.com/blog/?p=1#comments</comments>
		<pubDate>Sun, 23 Oct 2005 14:39:25 +0000</pubDate>
		<dc:creator>jlgauthier</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;ve had a rough history with blogging and websites&#8230; the chances I&#8217;ll be sharing my thoughts through this are pretty much zero. Setting it up was fun at least. I even came accross this neat Captcha thing, called re-Captcha. Apparently whenever you use it you are helping the world preserve books.
Which means the more I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a rough history with blogging and websites&#8230; the chances I&#8217;ll be sharing my thoughts through this are pretty much zero. Setting it up was fun at least. I even came accross this neat Captcha thing, called <a href="http://recaptcha.net/learnmore.html">re-Captcha</a>. Apparently whenever you use it you are helping the world preserve books.</p>
<p>Which means the more <em>I</em> post and the more <em>you</em> comment the more books our descendants will have access to. electronicly. So please comment, and make books available for our children. To encourage people to participate I&#8217;m not going to spell-check. That way if you are stuck with nothing relevent to say but still want to contribute to future generations you can correct my spelling&#8230; and I&#8217;ll match you with a comment (and another re-Captcha!) thanning you.</p>
]]></content:encoded>
			<wfw:commentRss>http://jlgauthier.com/blog/?feed=rss2&amp;p=1</wfw:commentRss>
		</item>
	</channel>
</rss>

