<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Analyzing bitmaps bigger than 512&#215;512</title>
	<atom:link href="http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/</link>
	<description>Actionscript3, Flash, Scala, Java, C#, C++, Algorithms &#38; Imageprocessing</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:26:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: joa</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55151</link>
		<dc:creator>joa</dc:creator>
		<pubDate>Wed, 29 Aug 2007 15:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55151</guid>
		<description>Personally I have a test environment where I run each test multiple times and get the average out of that. Possible parameters to change are number of tests, test iterations and some other things. A test is started after a delay of 10sec so it does not go with the launch of the Flash player. And tests have to be done in the release player because the debug player gives different results sometimes.

But even that is sometimes not telling the truth. André is using a Float class inside an array to store Numbers. A test showed that it is not faster to do that. Then he tested it in an audio filter and the Float was much faster. I tried to figure it but at the end the only answer would be reading of an array is not that heavy but writing to an array is which the test was not doing (just reading).</description>
		<content:encoded><![CDATA[<p>Personally I have a test environment where I run each test multiple times and get the average out of that. Possible parameters to change are number of tests, test iterations and some other things. A test is started after a delay of 10sec so it does not go with the launch of the Flash player. And tests have to be done in the release player because the debug player gives different results sometimes.</p>
<p>But even that is sometimes not telling the truth. André is using a Float class inside an array to store Numbers. A test showed that it is not faster to do that. Then he tested it in an audio filter and the Float was much faster. I tried to figure it but at the end the only answer would be reading of an array is not that heavy but writing to an array is which the test was not doing (just reading).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Klingemann</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55150</link>
		<dc:creator>Mario Klingemann</dc:creator>
		<pubDate>Wed, 29 Aug 2007 15:48:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55150</guid>
		<description>I&#039;m also getting big variations for certain tests. For example did I test exactly the same code in two different functions (test1() and test2()) and they  took different times to run. Seems like this depends on the room temperature. Also my getPixel() vs. getPixel32() test suddenly was slower again for getPixel32().

It would be really good to have a reliable setup for making these kind of tests.</description>
		<content:encoded><![CDATA[<p>I&#8217;m also getting big variations for certain tests. For example did I test exactly the same code in two different functions (test1() and test2()) and they  took different times to run. Seems like this depends on the room temperature. Also my getPixel() vs. getPixel32() test suddenly was slower again for getPixel32().</p>
<p>It would be really good to have a reliable setup for making these kind of tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joa</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55149</link>
		<dc:creator>joa</dc:creator>
		<pubDate>Wed, 29 Aug 2007 14:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55149</guid>
		<description>Actually I would like to know also why it is slower for smaller bitmaps. Maybe yours will be as fast as the simple for even if the size is below 1024.</description>
		<content:encoded><![CDATA[<p>Actually I would like to know also why it is slower for smaller bitmaps. Maybe yours will be as fast as the simple for even if the size is below 1024.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joa</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55148</link>
		<dc:creator>joa</dc:creator>
		<pubDate>Wed, 29 Aug 2007 14:50:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55148</guid>
		<description>On my machine this is slower compared 370 for this one to 350 average for the other one. But in fact I have some programs running now so the test is not very accurate.

I will do some more tests when I am done with work. And I will send you the test environment later as well.

But thinking about the memory structure. I think they store the BitmapData data (without the overhead) like rgb *bmp = new rgb[width*height]; (maybe not with the custom typedef -- im no c   expert). So it is a 1d array. The fastest way to loop through that would be a pointer of course. And if you can not use that it should be the loop you mentioned.

But the fact that the version with the while is slower for me now or at least not faster makes me a little bit perplex. But I will do some more tests when I have the time :)</description>
		<content:encoded><![CDATA[<p>On my machine this is slower compared 370 for this one to 350 average for the other one. But in fact I have some programs running now so the test is not very accurate.</p>
<p>I will do some more tests when I am done with work. And I will send you the test environment later as well.</p>
<p>But thinking about the memory structure. I think they store the BitmapData data (without the overhead) like rgb *bmp = new rgb[width*height]; (maybe not with the custom typedef &#8212; im no c   expert). So it is a 1d array. The fastest way to loop through that would be a pointer of course. And if you can not use that it should be the loop you mentioned.</p>
<p>But the fact that the version with the while is slower for me now or at least not faster makes me a little bit perplex. But I will do some more tests when I have the time :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Klingemann</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55147</link>
		<dc:creator>Mario Klingemann</dc:creator>
		<pubDate>Wed, 29 Aug 2007 14:34:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55147</guid>
		<description>Well... I&#039;ve modified your cycling code so it does not meander through the bitmap but just goes left-&gt;right, top-&gt;down and at least for me it is faster. Could you compare that on your machine?

private function test22(): int
{
var t0: int;
var t1: int;
var c0: int;

var y: int;
var x: int;
var m: Boolean = true;

t0 = getTimer();
while ( true )
{
c0 = bitmapData.getPixel32( x  , y );

if ( x == w )
{
if ( y   == h )
break;
x = 0;
}
}
t1 = getTimer();

return ( t1 - t0 );
}</description>
		<content:encoded><![CDATA[<p>Well&#8230; I&#8217;ve modified your cycling code so it does not meander through the bitmap but just goes left-&gt;right, top-&gt;down and at least for me it is faster. Could you compare that on your machine?</p>
<p>private function test22(): int<br />
{<br />
var t0: int;<br />
var t1: int;<br />
var c0: int;</p>
<p>var y: int;<br />
var x: int;<br />
var m: Boolean = true;</p>
<p>t0 = getTimer();<br />
while ( true )<br />
{<br />
c0 = bitmapData.getPixel32( x  , y );</p>
<p>if ( x == w )<br />
{<br />
if ( y   == h )<br />
break;<br />
x = 0;<br />
}<br />
}<br />
t1 = getTimer();</p>
<p>return ( t1 &#8211; t0 );<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Klingemann</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55146</link>
		<dc:creator>Mario Klingemann</dc:creator>
		<pubDate>Wed, 29 Aug 2007 14:24:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55146</guid>
		<description>My wild guess is that those speed differences are caused by the CPU&#039;s prefetch cache. On my notebook the difference is not as big as you have measured - it&#039;s only 1660ms (cycle) vs. 1850ms (simple) for a 2048x2048 BitmapData.

Usually it should be faster to loop through a bitmap in forward direction(aka x from 0 to width and y from 0 to height) since that is how a bitmap lies in memory and the processor can already prefetch the adjacent memory slots into the cache. 

Could you maybe publish the whole class that you used for testing? Like this we could get comparable results.

BTW - I noticed that for non-transparent bitmaps it is actually faster to read them with getPixel32().</description>
		<content:encoded><![CDATA[<p>My wild guess is that those speed differences are caused by the CPU&#8217;s prefetch cache. On my notebook the difference is not as big as you have measured &#8211; it&#8217;s only 1660ms (cycle) vs. 1850ms (simple) for a 2048&#215;2048 BitmapData.</p>
<p>Usually it should be faster to loop through a bitmap in forward direction(aka x from 0 to width and y from 0 to height) since that is how a bitmap lies in memory and the processor can already prefetch the adjacent memory slots into the cache. </p>
<p>Could you maybe publish the whole class that you used for testing? Like this we could get comparable results.</p>
<p>BTW &#8211; I noticed that for non-transparent bitmaps it is actually faster to read them with getPixel32().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joa</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55144</link>
		<dc:creator>joa</dc:creator>
		<pubDate>Wed, 29 Aug 2007 09:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55144</guid>
		<description>Well yes ;) You have to keep in mind that this is the width and height of the BitmapData. Is it now faster for you too?

I run each test 15 times and take the average of that. w and h are defined as 2048. bitmapData is a BitmapData object with width and height 2048 and no transparency.

The code:
&lt;code&gt;		private function test19(): int
		{
			var t0: int;
			var t1: int;
			var c0: int;
			
			var x: int;
			var y: int;
			
			t0 = getTimer();
			for ( ; x &lt; w; ++x )
				for ( y = 0; y &lt; h; ++y )
					c0 = bitmapData.getPixel( x, y );
			t1 = getTimer();
			
			return ( t1 - t0 );
		}


		private function test20(): int
		{
			var t0: int;
			var t1: int;
			var c0: int;
			
			var y: int;
			var x: int;
			var m: Boolean = true;
			
			t0 = getTimer();
			while ( true )
			{
				c0 = bitmapData.getPixel( m ? x++ : --x, y );
				
				if ( x == w &#124;&#124; x == 0 )
				{
					if ( y++ == h )
						break;
					m = !m;
				}
			}
			t1 = getTimer();
			
			return ( t1 - t0 );
		}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Well yes ;) You have to keep in mind that this is the width and height of the BitmapData. Is it now faster for you too?</p>
<p>I run each test 15 times and take the average of that. w and h are defined as 2048. bitmapData is a BitmapData object with width and height 2048 and no transparency.</p>
<p>The code:<br />
<code>		private function test19(): int<br />
		{<br />
			var t0: int;<br />
			var t1: int;<br />
			var c0: int;</p>
<p>			var x: int;<br />
			var y: int;</p>
<p>			t0 = getTimer();<br />
			for ( ; x < w; ++x )<br />
				for ( y = 0; y < h; ++y )<br />
					c0 = bitmapData.getPixel( x, y );<br />
			t1 = getTimer();</p>
<p>			return ( t1 - t0 );<br />
		}</p>
<p>		private function test20(): int<br />
		{<br />
			var t0: int;<br />
			var t1: int;<br />
			var c0: int;</p>
<p>			var y: int;<br />
			var x: int;<br />
			var m: Boolean = true;</p>
<p>			t0 = getTimer();<br />
			while ( true )<br />
			{<br />
				c0 = bitmapData.getPixel( m ? x++ : --x, y );</p>
<p>				if ( x == w || x == 0 )<br />
				{<br />
					if ( y++ == h )<br />
						break;<br />
					m = !m;<br />
				}<br />
			}<br />
			t1 = getTimer();</p>
<p>			return ( t1 - t0 );<br />
		}</code></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55143</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Wed, 29 Aug 2007 09:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55143</guid>
		<description>i found the mistake - i copied the snippet into a class which extends a Sprite and since width and height were never defined locally it took the properties of the display object :)</description>
		<content:encoded><![CDATA[<p>i found the mistake &#8211; i copied the snippet into a class which extends a Sprite and since width and height were never defined locally it took the properties of the display object :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pwd</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55142</link>
		<dc:creator>pwd</dc:creator>
		<pubDate>Wed, 29 Aug 2007 05:24:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55142</guid>
		<description>Sounds amazing. I´m looking forward to copy´n´paste your little snippet in my &quot;oldschool tunnel efx&quot; - maybe it´ll boost up the performance a bit...

Just have to find some sparetime! ;)

Cheers
pwd</description>
		<content:encoded><![CDATA[<p>Sounds amazing. I´m looking forward to copy´n´paste your little snippet in my &#8220;oldschool tunnel efx&#8221; &#8211; maybe it´ll boost up the performance a bit&#8230;</p>
<p>Just have to find some sparetime! ;)</p>
<p>Cheers<br />
pwd</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antti Kupila</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55141</link>
		<dc:creator>Antti Kupila</dc:creator>
		<pubDate>Wed, 29 Aug 2007 04:56:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55141</guid>
		<description>Oh, interesting! Thanks for sharing!

Does anybody know why this is happening? I mean, the difference according to your tests is quite big..</description>
		<content:encoded><![CDATA[<p>Oh, interesting! Thanks for sharing!</p>
<p>Does anybody know why this is happening? I mean, the difference according to your tests is quite big..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blog.joa-ebert.com/2007/08/28/analyzing-bitmaps-bigger-than-512x512/comment-page-1/#comment-55140</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Tue, 28 Aug 2007 21:50:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/08/28/analyzing-bitmaps-bigger-than-512x512/#comment-55140</guid>
		<description>hey joa, i copy &amp; pasted your code and strangely enough my results are: default for loop 816ms and cycle 1757ms (2048x2048). is there perhaps something wrong or missing in your code snippet ?</description>
		<content:encoded><![CDATA[<p>hey joa, i copy &amp; pasted your code and strangely enough my results are: default for loop 816ms and cycle 1757ms (2048&#215;2048). is there perhaps something wrong or missing in your code snippet ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

