<?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: Increment and Decrement</title>
	<atom:link href="http://jacksondunstan.com/articles/624/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/624</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Mon, 06 Sep 2010 21:17:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Ducky&#8217;s Tutorials # 28 &#8211; The Expression Gate &#8211; Part 2 &#124; Host Rage</title>
		<link>http://jacksondunstan.com/articles/624/comment-page-1#comment-606</link>
		<dc:creator>Ducky&#8217;s Tutorials # 28 &#8211; The Expression Gate &#8211; Part 2 &#124; Host Rage</dc:creator>
		<pubDate>Tue, 30 Mar 2010 03:45:55 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=624#comment-606</guid>
		<description>[...] Increment &amp;#1072&amp;#1495&amp;#1281 Decrement &#171; JacksonDunstan.com [...]</description>
		<content:encoded><![CDATA[<p>[...] Increment &amp;#1072&amp;#1495&amp;#1281 Decrement &laquo; JacksonDunstan.com [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sindisil</title>
		<link>http://jacksondunstan.com/articles/624/comment-page-1#comment-555</link>
		<dc:creator>Sindisil</dc:creator>
		<pubDate>Fri, 05 Mar 2010 22:35:57 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=624#comment-555</guid>
		<description>Yup, the bottom line is, it seldom matters - use the incr/decr form that&#039;s most comfortable.

Frankly, given the many other optimization opportunities that AS3 misses, I was mildly surprised that, when it&#039;s safe to, AVM2 optimizes away the temporary.

It&#039;s also important to note that the difference in performance, even when there is one, is too small to matter in the context of AS3. We&#039;re talking, at most, 50ms over 100,000,000 repetitions.

I just thought it was worth highlighting the different scenarios.</description>
		<content:encoded><![CDATA[<p>Yup, the bottom line is, it seldom matters &#8211; use the incr/decr form that&#8217;s most comfortable.</p>
<p>Frankly, given the many other optimization opportunities that AS3 misses, I was mildly surprised that, when it&#8217;s safe to, AVM2 optimizes away the temporary.</p>
<p>It&#8217;s also important to note that the difference in performance, even when there is one, is too small to matter in the context of AS3. We&#8217;re talking, at most, 50ms over 100,000,000 repetitions.</p>
<p>I just thought it was worth highlighting the different scenarios.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/624/comment-page-1#comment-554</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 05 Mar 2010 18:12:41 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=624#comment-554</guid>
		<description>This is a good point. My test only applies to simple increments and decrements where the value of the expression is not used. This is probably most uses though. Nevertheless, thanks for explaining this and providing your test results!</description>
		<content:encoded><![CDATA[<p>This is a good point. My test only applies to simple increments and decrements where the value of the expression is not used. This is probably most uses though. Nevertheless, thanks for explaining this and providing your test results!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sindisil</title>
		<link>http://jacksondunstan.com/articles/624/comment-page-1#comment-552</link>
		<dc:creator>Sindisil</dc:creator>
		<pubDate>Fri, 05 Mar 2010 16:38:38 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=624#comment-552</guid>
		<description>Your test misses an one aspect of the increment and decrement operators: the different semantics of the pre-fix and post-fix versions.

The value of the expression ++i is the value of &#039;i&#039; after increment.

The value of the expression i++ is the value of &#039;i&#039; before it is incremented.

The decrement operator has analogous semantics.

This means that the interpreter, or the code generated by the AVM2 JIT, must make a copy of the original value of the variable operated upon in the post-fix cases. This takes non-zero time.

In the case where the value of the increment or decrement expression is not used, the interpreter or JIT is free to optimize away the saving of the original value.

Changing the increment and decrement test stanzas to include assignment (e.g. change from &quot;j++&quot; to &quot;acc = j++&quot; and &quot;++j&quot; to &quot;acc = ++j&quot;) results in a difference in performance, albeit a minor one

My results on my netbook, running latest FP 10 release player in Firefox:

Increment:
	Post-increment (j++): 659
	Pre-increment (++j): 644
Decrement:
	Post-decrement (j--): 647
	Pre-decrement (--j): 584</description>
		<content:encoded><![CDATA[<p>Your test misses an one aspect of the increment and decrement operators: the different semantics of the pre-fix and post-fix versions.</p>
<p>The value of the expression ++i is the value of &#8216;i&#8217; after increment.</p>
<p>The value of the expression i++ is the value of &#8216;i&#8217; before it is incremented.</p>
<p>The decrement operator has analogous semantics.</p>
<p>This means that the interpreter, or the code generated by the AVM2 JIT, must make a copy of the original value of the variable operated upon in the post-fix cases. This takes non-zero time.</p>
<p>In the case where the value of the increment or decrement expression is not used, the interpreter or JIT is free to optimize away the saving of the original value.</p>
<p>Changing the increment and decrement test stanzas to include assignment (e.g. change from &#8220;j++&#8221; to &#8220;acc = j++&#8221; and &#8220;++j&#8221; to &#8220;acc = ++j&#8221;) results in a difference in performance, albeit a minor one</p>
<p>My results on my netbook, running latest FP 10 release player in Firefox:</p>
<p>Increment:<br />
	Post-increment (j++): 659<br />
	Pre-increment (++j): 644<br />
Decrement:<br />
	Post-decrement (j&#8211;): 647<br />
	Pre-decrement (&#8211;j): 584</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Richardson</title>
		<link>http://jacksondunstan.com/articles/624/comment-page-1#comment-551</link>
		<dc:creator>Simon Richardson</dc:creator>
		<pubDate>Fri, 05 Mar 2010 09:46:53 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=624#comment-551</guid>
		<description>I see a massive difference in the Debug player, but this shouldn&#039;t be used for Performance testing, so we can ignore this. I think people forget to switch to normal player when testing this stuff, which is why people see them as a performance difference. 

I do get this though running 1000000000 iterations in the standalone (the debug player wouldn&#039;t play this!). As you can see there is absolutely no real difference because the differences are so tight.

Increment:
	Post-increment (j++): 2771
	Pre-increment (++j): 2778
	Add 1 (j+=1): 2814
Decrement:
	Post-decrement (j--): 2776
	Pre-decrement (--j): 2864
	Subtract 1 (j-=1): 2839</description>
		<content:encoded><![CDATA[<p>I see a massive difference in the Debug player, but this shouldn&#8217;t be used for Performance testing, so we can ignore this. I think people forget to switch to normal player when testing this stuff, which is why people see them as a performance difference. </p>
<p>I do get this though running 1000000000 iterations in the standalone (the debug player wouldn&#8217;t play this!). As you can see there is absolutely no real difference because the differences are so tight.</p>
<p>Increment:<br />
	Post-increment (j++): 2771<br />
	Pre-increment (++j): 2778<br />
	Add 1 (j+=1): 2814<br />
Decrement:<br />
	Post-decrement (j&#8211;): 2776<br />
	Pre-decrement (&#8211;j): 2864<br />
	Subtract 1 (j-=1): 2839</p>
]]></content:encoded>
	</item>
</channel>
</rss>
