<?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>labs.hellokeita.com &#187; Benchmark</title>
	<atom:link href="http://labs.hellokeita.com/category/benchmark/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.hellokeita.com</link>
	<description>Yet another labs blog</description>
	<lastBuildDate>Mon, 02 Aug 2010 11:20:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fast Metaball Effect in AS3</title>
		<link>http://labs.hellokeita.com/2010/08/02/fast-metaball-effect-in-as3/</link>
		<comments>http://labs.hellokeita.com/2010/08/02/fast-metaball-effect-in-as3/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 11:20:27 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Flash CS4]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[metaball]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/?p=121</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_metaball_1165711587"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/files/metaball/metaball.swf" />
	<param name="bgcolor" value="#000000" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/metaball/metaball.swf"
			name="fm_metaball_1165711587"
			width="400"
			height="300">
		<param name="bgcolor" value="#000000" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

var container:Sprite = new Sprite();
var balls:Vector. = new Vector.();
var m:Matrix;
var s:Shape;
var r:Number;
var c:uint;
for(var i:int = 0; i < 10; i++){
	r = Math.random() * 100 + 100;
	m = new Matrix();
	m.createGradientBox(r, r, 0, -r * 0.5, -r * 0.5);
	s = container.addChild(new Shape()) as Shape;
	c = Math.random() * 0xFFFFFF;
	s.graphics.beginGradientFill(GradientType.RADIAL, [c, c], [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_metaball_1533998288"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/files/metaball/metaball.swf" />
	<param name="bgcolor" value="#000000" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/metaball/metaball.swf"
			name="fm_metaball_1533998288"
			width="400"
			height="300">
		<param name="bgcolor" value="#000000" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><code><br />
var container:Sprite = new Sprite();<br />
var balls:Vector.<Shape> = new Vector.<Shape>();<br />
var m:Matrix;<br />
var s:Shape;<br />
var r:Number;<br />
var c:uint;<br />
for(var i:int = 0; i < 10; i++){<br />
	r = Math.random() * 100 + 100;<br />
	m = new Matrix();<br />
	m.createGradientBox(r, r, 0, -r * 0.5, -r * 0.5);<br />
	s = container.addChild(new Shape()) as Shape;<br />
	c = Math.random() * 0xFFFFFF;<br />
	s.graphics.beginGradientFill(GradientType.RADIAL, [c, c], [1, 0], [0x00, 0xFF], m);<br />
	s.graphics.drawRect(-r * 0.5, -r * 0.5, r, r);<br />
	s.x = Math.random() * 400;<br />
	s.y = Math.random() * 300;<br />
	moveBall(s);<br />
	balls.push(s);<br />
}<br />
function moveBall(s:Shape):void<br />
{<br />
//whatever easing to move the spheres<br />
}<br />
var s2:Shape = container.addChild(new Shape()) as Shape;<br />
m = new Matrix();<br />
m.createGradientBox(200, 200, 0, -100, -100);<br />
c = Math.random() * 0xFFFFFF;<br />
s2.graphics.beginGradientFill(GradientType.RADIAL, [c, c], [1, 0], [0x00, 0xFF], m);<br />
s2.graphics.drawRect(-100, -100, 200, 200);<br />
var bmpData:BitmapData = new BitmapData(400, 300, true, 0x00000000);<br />
var bmp:Bitmap = addChild(new Bitmap(bmpData)) as Bitmap;<br />
addEventListener(Event.ENTER_FRAME, render);<br />
function render(e:Event):void<br />
{<br />
	s2.x = mouseX;<br />
	s2.y = mouseY;<br />
	bmpData.applyFilter(bmpData, bmpData.rect, new Point(0, 0), new BlurFilter(2, 2, 2));<br />
	bmpData.draw(container);<br />
	var i:int, l:int;<br />
	var aArr:Array = [];<br />
	var c:int;<br />
	for(i = 0; i <= 0xFF; i++)<br />
	{<br />
		c = (i - 0x80) << 1;<br />
		if(c < 0) c = 0;<br />
		aArr[i] = c << 24;<br />
	}<br />
	bmpData.paletteMap(bmpData, bmpData.rect, new Point(0, 0), null, null, null, aArr);<br />
}<br />
</code></p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2010/08/02/fast-metaball-effect-in-as3/&ztz=Fast Metaball Effect in AS3'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2010/08/02/fast-metaball-effect-in-as3/&ztz=Fast Metaball Effect in AS3'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2010/08/02/fast-metaball-effect-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BitmapData.lock benchmark</title>
		<link>http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/</link>
		<comments>http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 10:22:34 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Sandy3d]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/</guid>
		<description><![CDATA[Well, I don&#8217;t know if anybody read the Thomas Pfeiffer aka Kiroukou (the Sandy3D creator and project leader) commented on my previous post.
Here&#8217;s what he said.
 Indeed Sandy does a clone of the original texture, for few reasons:
- avoid an unfortunate dispose call.
- allowing to have a setTransparency method to dynamically change the transparency without [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I don&#8217;t know if anybody read the Thomas Pfeiffer aka Kiroukou (the <a href="http://www.flashsandy.org/" target="_blank">Sandy3D</a> creator and project leader) commented on my <a href="http://labs.hellokeita.com/2007/11/28/bitmapmaterial-tips/#comments" target="_blank">previous post</a>.<br />
Here&#8217;s what he said.</p>
<blockquote><p> Indeed Sandy does a clone of the original texture, for few reasons:<br />
- avoid an unfortunate dispose call.<br />
- allowing to have a setTransparency method to dynamically change the transparency without changing the original bitmapdata of the user.</p>
<p>Concerning the lock() and unclock() are you sure it has a performance impact?<br />
as far I know, this can’t provide any performance boost since the bitmapdata isn’t attached to the flash display list. When the object is out of stage, there’s no advantage to lock it.<br />
But I’d be interessted to have your feedback about that, and your performance test.</p></blockquote>
<p>About the BitmapData.clone(), he got his point.<br />
It just don&#8217;t work for me because I&#8217;m using too many 3d Objects with different BitmapMaterial for each, so, the system memory gets too high.<br />
But, about the setTransparency method, he is right.</p>
<p>About the lock and unlock methods, I runned a little benchmark test, because I got curious too how much performance boost you can get.<br />
Here&#8217;s the two test I made. (Clicking on the flash area it will re-run the benchmark test)</p>
<p>Using the lock and unlock methods.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_bitmapLockBenchmark_2044753567"
			class="flashmovie"
			width="200"
			height="30">
	<param name="movie" value="/files/benchmark/20071203/bitmapLockBenchmark.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071203/bitmapLockBenchmark.swf"
			name="fm_bitmapLockBenchmark_2044753567"
			width="200"
			height="30">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Not using the lock and unlock methods.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_noBitmapLockBenchmark_689383996"
			class="flashmovie"
			width="200"
			height="30">
	<param name="movie" value="/files/benchmark/20071203/noBitmapLockBenchmark.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071203/noBitmapLockBenchmark.swf"
			name="fm_noBitmapLockBenchmark_689383996"
			width="200"
			height="30">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>It&#8217;s a really simple test, just to make a benchmark test.<br />
Actually, it&#8217;s not a situation that uses any 3d framework.</p>
<p>Creating a BitmapData.<br />
Creating 1000 Bitmaps.<br />
Applying 1000 times a BlurFilter over the BitmapData.</p>
<p>On my PC I get about 150ms faster with locking the BitmapData.</p>
<p>keita</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/&ztz=BitmapData.lock benchmark'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/&ztz=BitmapData.lock benchmark'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2007/12/04/bitmapdatalock-benchmark/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BitmapData.draw x Graphics.beginBitmapFill</title>
		<link>http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/</link>
		<comments>http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 16:12:57 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/</guid>
		<description><![CDATA[Firstly&#8230; sorry for my poor English&#8230;
Working on Recyou.jp, I had to use many BitmapDatas, and so, I had to work out some way to make it lighter.
One thing I realized is that using Graphics.beginBitmapFill besides BitmapData.draw its much faster.
I made the benchmarks, drawing 10000 bitmapDatas, one using BitmapData.draw, and other using Graphics.beginBitmapFill.
First the benchmark with [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly&#8230; sorry for my poor English&#8230;</p>
<p>Working on Recyou.jp, I had to use many BitmapDatas, and so, I had to work out some way to make it lighter.<br />
One thing I realized is that using Graphics.beginBitmapFill besides BitmapData.draw its much faster.</p>
<p>I made the benchmarks, drawing 10000 bitmapDatas, one using BitmapData.draw, and other using Graphics.beginBitmapFill.</p>
<p>First the benchmark with BitmapData.draw (Clicking on the flash it will re-run the benchmark):<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_b1_1227907865"
			class="flashmovie"
			width="200"
			height="40">
	<param name="movie" value="/files/benchmark/20071108/b1.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071108/b1.swf"
			name="fm_b1_1227907865"
			width="200"
			height="40">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
The code is something like this:<br />
[code lang="actionscript"]<br />
var genericBmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
var bmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
for(var i = 0; i &lt; 10000; i++){<br />
bmp.draw(genericBmp);<br />
}<br />
[/code]</p>
<p>Now the benchmark with Graphics.beginBitmapFill (Clicking on the flash it will re-run the benchmark):<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_b2_1688159346"
			class="flashmovie"
			width="200"
			height="40">
	<param name="movie" value="/files/benchmark/20071108/b2.swf" />
	<param name="bgcolor" value="#f9f9f9" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/benchmark/20071108/b2.swf"
			name="fm_b2_1688159346"
			width="200"
			height="40">
		<param name="bgcolor" value="#f9f9f9" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
The code is something like this:<br />
[code lang="actionscript"]<br />
var genericBmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
var bmp:BitmapData = new BitmapData(100,100, false, 0x000000);<br />
for(var i = 0; i &lt; 10000; i++){<br />
graphics.beginBitmapFill(genericBmp);<br />
graphics.drawRect(0,0,100,100);<br />
}<br />
[/code]</p>
<p>So, if you are trying to create some bitmap pattens or attaching a Bitmap child and redrawing it&#8217;s BitmapData, try using the Graphics.beginBitmapFill.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/&ztz=BitmapData.draw x Graphics.beginBitmapFill'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/&ztz=BitmapData.draw x Graphics.beginBitmapFill'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2007/11/08/bitmapdatadraw-x-graphicsbeginbitmapfill/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
