<?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: Cycling through the Integer range &#8211; A Fermi problem</title>
	<atom:link href="http://www.javatuning.com/cycling-through-the-integer-range-a-fermi-problem/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javatuning.com/cycling-through-the-integer-range-a-fermi-problem/</link>
	<description>Software Development, Java, and some more.</description>
	<lastBuildDate>Tue, 15 Nov 2011 03:25:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Preston Pfarner</title>
		<link>http://www.javatuning.com/cycling-through-the-integer-range-a-fermi-problem/comment-page-1/#comment-10</link>
		<dc:creator>Preston Pfarner</dc:creator>
		<pubDate>Mon, 30 Jun 2008 03:59:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.javatuning.com/?p=16#comment-10</guid>
		<description>Don&#039;t forget optimization.  Just because you tell it to run that code doesn&#039;t mean it really will.

Using the 64-bit Linux version of Sun&#039;s 1.6.0_03-b05 JDK, it completes in 1ms for me (yes, I mean 0.001s).  Using the 64-bit version of OpenJDK&#039;s 1.6.0-b09 JDK, it takes 4ms.  Both runs were on an otherwise mostly idle Intel Q6600, using one of its 2.4GHz cores.  This is pretty consistent on repeated trials.

However, I agree with your assessment of the approximate amount of time it would have to take to compute that loop, so it must be choosing not to run the loop.  It&#039;s allowed to make that decision, as there are no side effects.

According to &quot;javap -c&quot;, the loop code is still present in the bytecode.  And if I run with the -Xint flag, then those times jump up to 57.4s for both Sun 1.6.0_03-b05 and OpenJDK 1.6.0-b09.  The interpreted runs are still performing the loop calculations.

If I change the code, so it has a side effect that the compiler can&#039;t optimize, I can force it to keep the loop (though it may make other changes, like unrolling it partially).  I created a long variable &quot;dummy&quot;, and then put &quot;dummy *= 3;&quot; inside the loop.  That slows both native implementations down to 5.43s, which is in the ballpark you&#039;re describing.  It&#039;s actually running the loop.

Interestingly, if I only have &quot;++dummy;&quot; inside the loop, the optimizer is able to infer the results of that calculation; it takes only 0.16sec to do that (again with approximately equal times from both JDKs).</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget optimization.  Just because you tell it to run that code doesn&#8217;t mean it really will.</p>
<p>Using the 64-bit Linux version of Sun&#8217;s 1.6.0_03-b05 JDK, it completes in 1ms for me (yes, I mean 0.001s).  Using the 64-bit version of OpenJDK&#8217;s 1.6.0-b09 JDK, it takes 4ms.  Both runs were on an otherwise mostly idle Intel Q6600, using one of its 2.4GHz cores.  This is pretty consistent on repeated trials.</p>
<p>However, I agree with your assessment of the approximate amount of time it would have to take to compute that loop, so it must be choosing not to run the loop.  It&#8217;s allowed to make that decision, as there are no side effects.</p>
<p>According to &#8220;javap -c&#8221;, the loop code is still present in the bytecode.  And if I run with the -Xint flag, then those times jump up to 57.4s for both Sun 1.6.0_03-b05 and OpenJDK 1.6.0-b09.  The interpreted runs are still performing the loop calculations.</p>
<p>If I change the code, so it has a side effect that the compiler can&#8217;t optimize, I can force it to keep the loop (though it may make other changes, like unrolling it partially).  I created a long variable &#8220;dummy&#8221;, and then put &#8220;dummy *= 3;&#8221; inside the loop.  That slows both native implementations down to 5.43s, which is in the ballpark you&#8217;re describing.  It&#8217;s actually running the loop.</p>
<p>Interestingly, if I only have &#8220;++dummy;&#8221; inside the loop, the optimizer is able to infer the results of that calculation; it takes only 0.16sec to do that (again with approximately equal times from both JDKs).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allan McLemore</title>
		<link>http://www.javatuning.com/cycling-through-the-integer-range-a-fermi-problem/comment-page-1/#comment-6</link>
		<dc:creator>Allan McLemore</dc:creator>
		<pubDate>Sun, 15 Jun 2008 23:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.javatuning.com/?p=16#comment-6</guid>
		<description>Software companies love to ask questions like “How many gas stations are in Cleveland?”. Here’s my thoughts on why they do this: http://www.zenternal.com/weblog/index.php/2008/06/15/fermi-problems-ie-how-many-iphones-are-in-austin/</description>
		<content:encoded><![CDATA[<p>Software companies love to ask questions like “How many gas stations are in Cleveland?”. Here’s my thoughts on why they do this: <a href="http://www.zenternal.com/weblog/index.php/2008/06/15/fermi-problems-ie-how-many-iphones-are-in-austin/" rel="nofollow">http://www.zenternal.com/weblog/index.php/2008/06/15/fermi-problems-ie-how-many-iphones-are-in-austin/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

