<?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>bindable &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/bindable/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Thu, 24 Jun 2010 07:36:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>bindable &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>[Bindable]? No, thanks</title>
		<link>https://blog.sephiroth.it/2009/07/25/bindable-no-thanks/</link>
					<comments>https://blog.sephiroth.it/2009/07/25/bindable-no-thanks/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 01:20:08 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[actioscript]]></category>
		<category><![CDATA[bindable]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=276</guid>

					<description><![CDATA[Working on huge projects sometimes let you take long optimization sessions. During one of these sessions I was trying to find a way to optimize a bunch of code which was taking too long time to process. The big big bottleneck I discovered, and I didn&#8217;t know before (my fault), was the **[Bindable]** attribute of &#8230; <a href="https://blog.sephiroth.it/2009/07/25/bindable-no-thanks/" class="more-link">Continue reading <span class="screen-reader-text">[Bindable]? No, thanks</span></a>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignleft size-thumbnail wp-image-394" style="margin: 4px;" title="flash_builder_logo" src="https://blog.sephiroth.it/wp-content/uploads/2010/01/flash_builder_logo-150x150.png" alt="" width="150" height="150" srcset="https://blog.sephiroth.it/wp-content/uploads/2010/01/flash_builder_logo-150x149.png 150w, https://blog.sephiroth.it/wp-content/uploads/2010/01/flash_builder_logo-64x64.png 64w, https://blog.sephiroth.it/wp-content/uploads/2010/01/flash_builder_logo.png 300w" sizes="(max-width: 150px) 100vw, 150px" />Working on huge projects sometimes let you take long optimization sessions.<br />
 During one of these sessions I was trying to find a way to optimize a bunch of code which was taking too long time to process.<br />
 The big big bottleneck I discovered, and I didn&#8217;t know before (my fault), was the **[Bindable]** attribute of one of the classes included in the process.<br />
 This process was creating something like 1 million instances of this class during its life. After a first optimization in which I created an object pooling, thus reducing the total execution time from 16 seconds to 13, I found this incredible trick which reduced the total execution time to **1 second!!**</p>
<p>Let&#8217;s say you have a class like this:</p>
<p><code lang="actionscript3">package it.sepy.test<br />
{</p>
<p>	[Bindable]<br />
	public class RGB<br />
	{<br />
		private var _blue: int;<br />
		private var _green: int;<br />
		private var _red: int;</p>
<p>		public function RGB()<br />
		{<br />
		}</p>
<p>		public function get blue(): int<br />
		{<br />
			return _blue;<br />
		}</p>
<p>		public function set blue( v: int ): void<br />
		{<br />
			_blue = v;<br />
		}</p>
<p>		public function get green(): int<br />
		{<br />
			return _green;<br />
		}</p>
<p>		public function set green( v: int ): void<br />
		{<br />
			_green = v;<br />
		}</p>
<p>		public function get red(): int<br />
		{<br />
			return _red;<br />
		}</p>
<p>		public function set red( v: int ): void<br />
		{<br />
			_red = v;<br />
		}<br />
	}<br />
}<br />
</code></p>
<p>and a simple script which create 100000 instances of this class (my script wasn&#8217;t like this, but for simplicity I&#8217;m doing this example):</p>
<p><code lang="actionscript3"><br />
package<br />
{<br />
	import flash.display.Sprite;<br />
	import flash.system.System;<br />
	import it.sepy.test.Pool;<br />
	import it.sepy.test.RGB;</p>
<p>	public class test extends Sprite<br />
	{<br />
		public function test()<br />
		{<br />
			startTest();<br />
		}</p>
<p>		private function startTest(): void<br />
		{<br />
			var t1: Number = new Date().getTime();<br />
			for ( var i: int = 0; i < 100000; i++ )
			{
				var rgb: RGB = new RGB();
				rgb.red = i % 255;
				rgb.green = i % 255;
				rgb.blue = i % 255;
			}

			var t2: Number = new Date().getTime();
			trace( 'total execution time:', ( t2 - t1 ), 'ms' );
			trace( 'memory usage:', System.totalMemory / 1024, 'kb' );
		}
	}
}
</code></p>
<p>now launch the script and in the output I have this result<br />
 <strong> total execution time: 2381 ms<br />
 memory usage: 5924 kb</strong></p>
<p>NOW. Remove the **[Bindable]** property from the RGB class and launch again the test script. See at the output console and the new results are:<br />
 <strong> total execution time: 236 ms<br />
 memory usage: 2720 kb</strong></p>
<p>So, I know that bindable were not created for this kind of jobs, but if using it make 10 time slower my scripts, then I don't see any valid reason to use it anywhere.</p>
<p></code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2009/07/25/bindable-no-thanks/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
