<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Code movement in Java programs with pure functions</title>
	<atom:link href="http://purejava.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://purejava.wordpress.com</link>
	<description>A journal of my research for a BSc (Hons) project at VUW</description>
	<lastBuildDate>Sun, 12 Oct 2008 11:32:02 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='purejava.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a849b44995be1f0c602d44bef58fb91e?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Code movement in Java programs with pure functions</title>
		<link>http://purejava.wordpress.com</link>
	</image>
			<item>
		<title>Submitted</title>
		<link>http://purejava.wordpress.com/2008/10/12/submitted/</link>
		<comments>http://purejava.wordpress.com/2008/10/12/submitted/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 11:31:19 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[finished]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[submitted]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=66</guid>
		<description><![CDATA[I have just submitted my final report. There are still many things that I could improve, including many comments and suggested changes from my supervisors (Lindsay in particular) and from Craig and other postgrad students. I could probably submit a new version sometime today as Dave has told his students (including me) that they can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=66&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have just submitted my final report. There are still many things that I could improve, including many comments and suggested changes from my supervisors (Lindsay in particular) and from Craig and other postgrad students. I could probably submit a new version sometime today as Dave has told his students (including me) that they can submit late, but I really do not feel like doing so. Anyway, <a href="http://q.geek.nz/files/COMP489/final_report.pdf">here it is</a> for you reading pleasure.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=66&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/10/12/submitted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing final report</title>
		<link>http://purejava.wordpress.com/2008/10/03/writing-final-report/</link>
		<comments>http://purejava.wordpress.com/2008/10/03/writing-final-report/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 06:03:22 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[honours]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=64</guid>
		<description><![CDATA[I have been quite busy lately writing my final report for this honours project, which is due at 11:59 pm on Sunday 12th October. The page limit is 40 pages; I currently have 30 (though only 22 of those are the body, once the title page, contents, bibliography etc. is taken out). I sent a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=64&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have been quite busy lately writing my final report for this honours project, which is due at 11:59 pm on Sunday 12th October. The page limit is 40 pages; I currently have 30 (though only 22 of those are the body, once the title page, contents, bibliography etc. is taken out). I sent a second draft to my supervisors this afternoon with the introduction written (among other things), but there is still a lot to do, and I have many other assignments and projects due around the same time.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=64&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/10/03/writing-final-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>Poster submitted</title>
		<link>http://purejava.wordpress.com/2008/09/21/poster-submitted/</link>
		<comments>http://purejava.wordpress.com/2008/09/21/poster-submitted/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 10:02:34 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[poster]]></category>
		<category><![CDATA[report]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=60</guid>
		<description><![CDATA[I have submitted the soft-copy of my poster. Now it just remains to print it out in colour and stick it together for the poster presentations on Wednesday.
Now to get on with my final report, due all too soon&#8230;
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=60&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have submitted <a href='http://purejava.files.wordpress.com/2008/09/poster.pdf'>the soft-copy of my poster</a>. Now it just remains to print it out in colour and stick it together for the poster presentations on Wednesday.</p>
<p>Now to get on with my final report, due all too soon&#8230;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=60&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/09/21/poster-submitted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>Postering continues</title>
		<link>http://purejava.wordpress.com/2008/09/19/postering-continues/</link>
		<comments>http://purejava.wordpress.com/2008/09/19/postering-continues/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 03:06:27 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[honours]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[poster]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=57</guid>
		<description><![CDATA[I have spent the last week working on my poster, which is coming along slowly. I will post it here after I submit it on Sunday. I am getting varying advice, but it seems I have to cut down on the amount of text. It could also do with some better graphic design, though that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=57&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have spent the last week working on my poster, which is coming along slowly. I will post it here after I submit it on Sunday. I am getting varying advice, but it seems I have to cut down on the amount of text. It could also do with some better graphic design, though that may not happen.</p>
<p>Also, Stephen Nelson just pointed me to a paper <a href="http://lambda-the-ultimate.org/node/2993">Verifiable Functional Purity in Java</a> which looks interesting.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=57&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/09/19/postering-continues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>What I have been doing</title>
		<link>http://purejava.wordpress.com/2008/09/12/what-i-have-been-doing/</link>
		<comments>http://purejava.wordpress.com/2008/09/12/what-i-have-been-doing/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 11:06:34 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[optimisations]]></category>
		<category><![CDATA[poster]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=55</guid>
		<description><![CDATA[Since my last post, I have made another version of the IntersectSquares test, this one using a list class rather than just an array. There were again speed improvements found, but not quite so striking.
Other than that, I have started to prepare my poster (which is due Sunday week, 2008-09-21). Alex gave a talk yesterday [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=55&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Since my last post, I have made another version of the IntersectSquares test, this one using a list class rather than just an array. There were again speed improvements found, but not quite so striking.</p>
<p>Other than that, I have started to prepare my poster (which is due Sunday week, 2008-09-21). Alex gave a talk yesterday with some general advice on how to make good posters, and I talked a bit to my supervisors today about it. I am getting some conflicting advice, though, about how to structure the poster, which parts to emphasise more, where to include examples, and so on.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/purejava.wordpress.com/55/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/purejava.wordpress.com/55/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=55&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/09/12/what-i-have-been-doing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>More testing</title>
		<link>http://purejava.wordpress.com/2008/09/03/more-testing/</link>
		<comments>http://purejava.wordpress.com/2008/09/03/more-testing/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 05:21:00 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code movement]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[loop factoring]]></category>
		<category><![CDATA[optimisations]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=53</guid>
		<description><![CDATA[I wrote a slightly more interesting program called IntersectSquares, which generates an array of a large number of rectangles, then counts how many times they intersect each other. This is written in a fairly naive way, so there are a fair few expression for the optimiser to move out of the loop. I tried it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=53&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I wrote a slightly more interesting program called IntersectSquares, which generates an array of a large number of rectangles, then counts how many times they intersect each other. This is written in a fairly naive way, so there are a fair few expression for the optimiser to move out of the loop. I tried it here with 100,000 rectangles:</p>
<p>With jkit:<br />
<code><br />
andrew@rise:test cases$ time java IntersectSquares; time java IntersectSquares<br />
3290 intersections</p>
<p>real    0m58.843s<br />
user    0m58.470s<br />
sys     0m0.020s<br />
3290 intersections</p>
<p>real    0m58.918s<br />
user    0m58.491s<br />
sys     0m0.040s<br />
</code></p>
<p>With javac:<br />
<code><br />
andrew@rise:test cases$ time java IntersectSquares; time java IntersectSquares; time java IntersectSquares<br />
3290 intersections</p>
<p>real    1m4.690s<br />
user    1m3.783s<br />
sys     0m0.030s<br />
3290 intersections</p>
<p>real    1m4.908s<br />
user    1m3.805s<br />
sys     0m0.051s<br />
3290 intersections</p>
<p>real    1m4.209s<br />
user    1m3.695s<br />
sys     0m0.041s<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/purejava.wordpress.com/53/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/purejava.wordpress.com/53/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=53&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/09/03/more-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>A more successful test</title>
		<link>http://purejava.wordpress.com/2008/08/24/a-more-successful-test/</link>
		<comments>http://purejava.wordpress.com/2008/08/24/a-more-successful-test/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 08:35:52 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[loop invariant code movement]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[optiisation]]></category>
		<category><![CDATA[success]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=50</guid>
		<description><![CDATA[Talking to a friend this afternoon, I thought of another case that might be relatively common where my optimisation would apply and potentially save a fair bit of time. The situation is where two nested loops are used to loop through different arrays or lists, and then inside the inner loop are expressions that reference [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=50&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Talking to a friend this afternoon, I thought of another case that might be relatively common where my optimisation would apply and potentially save a fair bit of time. The situation is where two nested loops are used to loop through different arrays or lists, and then inside the inner loop are expressions that reference particular values from the collections indexed by their respective loop variables. To look at it another way, this sort of pattern is working with the Cartesian product of the two arrays.</p>
<p>Here is a simple example:<br />
<code><br />
@Unique int[] a = new int[10000];<br />
@Unique int[] b = new int[20000];</p>
<p>int sum = 0;</p>
<p>for (int i = 0; i &lt; a.length; ++i) {<br />
	for (int j = 0; j &lt; b.length; ++j) {<br />
		sum += a[i] * b[j];<br />
	}<br />
}</p>
<p>System.out.println("Sum: " + sum);<br />
</code></p>
<p>My optimisations move 3 expressions: <tt>a.length</tt> and <tt>b.length</tt> can be moved out of both loops, while <tt>a[i]</tt> can be moved out of the inner loop. It is this latter optimisation that is the most helpful.</p>
<p>Compiling this with JKit with and without my optimisations and then running with Sun Java 1.6.0 gives these times:<br />
Without optimisation:<br />
<code><br />
$ time java NestedProduct<br />
Sum: 0</p>
<p>real    0m0.923s<br />
user    0m0.829s<br />
sys     0m0.051s<br />
</code><br />
With optimisation:<br />
<code><br />
$ time java NestedProduct<br />
Sum: 0</p>
<p>real    0m0.724s<br />
user    0m0.657s<br />
sys     0m0.019s<br />
</code></p>
<p>Supporting code movement in this case required a few changes to my JKit stage, so it will be interesting to see if this allows any more optimisation in my evaluation programs as well.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/purejava.wordpress.com/50/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/purejava.wordpress.com/50/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=50&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/08/24/a-more-successful-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>Testing a few different JVMs</title>
		<link>http://purejava.wordpress.com/2008/08/23/testing-a-few-different-jvms/</link>
		<comments>http://purejava.wordpress.com/2008/08/23/testing-a-few-different-jvms/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 01:24:51 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[HotSpot]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[optimisation]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=45</guid>
		<description><![CDATA[So I found that Sun&#8217;s HotSpot Java VM does a fair bit of optimisation, and so the cases where my optimisations actually improve program performance are more limited than I thought they might have been. However, there are plenty of other JVMs around without so much run-time optimisation. I have tested here a number of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=45&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So I found that Sun&#8217;s HotSpot Java VM does a fair bit of optimisation, and so the cases where my optimisations actually improve program performance are more limited than I thought they might have been. However, there are plenty of other JVMs around without so much run-time optimisation. I have tested here a number of free JVMs, but it is likely that similar results would be found in the JVMs used on many small devices such as cellphones.</p>
<p>I tried <a href="http://en.wikipedia.org/wiki/JamVM">JamVM</a>, <a href="http://en.wikipedia.org/wiki/GNU_Interpreter_for_Java">GIJ</a>, <a href="http://en.wikipedia.org/wiki/CACAO">CACAO</a> and <a href="http://en.wikipedia.org/wiki/Kaffe">Kaffe</a>, as well as Sun Java 1.5.0 and 1.6.0 for comparison.</p>
<p>Here are the times I got (running a similar test to last time, though not using interfaces to confuse the JIT optimiser and using a smaller size for the test as some of the VMs were quite slow):<br />
<code><br />
andrew@rimu:~/COMP489/test cases$ java ManualMethod #Sun Java 1.6.0_07<br />
Normal: 15 ms<br />
Normal: 34 ms<br />
Normal: 32 ms<br />
Factored: 32 ms<br />
Factored: 31 ms<br />
Factored: 29 ms<br />
Side effects: 0<br />
andrew@rimu:~/COMP489/test cases$ java ManualMethod #Sun Java 1.5.0<br />
Normal: 46 ms<br />
Normal: 46 ms<br />
Normal: 46 ms<br />
Factored: 61 ms<br />
Factored: 39 ms<br />
Factored: 39 ms<br />
Side effects: 0<br />
andrew@rimu:~/COMP489/test cases$ jamvm ManualMethod<br />
Normal: 812 ms<br />
Normal: 837 ms<br />
Normal: 825 ms<br />
Factored: 230 ms<br />
Factored: 230 ms<br />
Factored: 241 ms<br />
Side effects: 0<br />
andrew@rimu:~/COMP489/test cases$ gij ManualMethod<br />
Normal: 3288 ms<br />
Normal: 3228 ms<br />
Normal: 3188 ms<br />
Factored: 287 ms<br />
Factored: 287 ms<br />
Factored: 286 ms<br />
Side effects: 0<br />
andrew@rimu:~/COMP489/test cases$ cacao ManualMethod<br />
Normal: 65 ms<br />
Normal: 76 ms<br />
Normal: 76 ms<br />
Factored: 11 ms<br />
Factored: 10 ms<br />
Factored: 11 ms<br />
Side effects: 0<br />
andrew@rimu:~/COMP489/test cases$ kaffe ManualMethod<br />
Normal: 284 ms<br />
Normal: 307 ms<br />
Normal: 317 ms<br />
Factored: 10 ms<br />
Factored: 10 ms<br />
Factored: 10 ms<br />
Side effects: 0<br />
</code></p>
<p>It seems from this that many VMs have less (or perhaps no) optimisation and greater overheads to method calls, and so in these cases my optimisations are quite helpful. Even the older 1.5.0 version of Sun&#8217;s HotSpot VM seems to benefit from my optimisations to the bytecode.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/purejava.wordpress.com/45/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/purejava.wordpress.com/45/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=45&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/08/23/testing-a-few-different-jvms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>You are doing it wrong&#8230;</title>
		<link>http://purejava.wordpress.com/2008/08/21/you-are-doing-it-wrong/</link>
		<comments>http://purejava.wordpress.com/2008/08/21/you-are-doing-it-wrong/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 10:10:28 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[antioptimisation]]></category>
		<category><![CDATA[evaluation]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=43</guid>
		<description><![CDATA[SimpleLisp is an interpreter, written in Java, for a limited dialect of LISP. I have been using it as an example Java program to evaluate my compiler optimisations. I just tried running a simple Lisp program (to calculate the Fibonacci sequence) in SimpleLisp to see the affect of my optimisations on the run time. Here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=43&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>SimpleLisp is an interpreter, written in Java, for a limited dialect of LISP. I have been using it as an example Java program to evaluate my compiler optimisations. I just tried running a simple Lisp program (to calculate the Fibonacci sequence) in SimpleLisp to see the affect of my optimisations on the run time. Here are some results.</p>
<p>SimpleLisp compiled with jkit, without my optimisation stage:<br />
<code><br />
$ time java org/simplelisp/interpreter/Interpreter examples/Fibonacci.sl<br />
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393</p>
<p>real    0m3.380s<br />
user    0m3.294s<br />
sys     0m0.031s<br />
</code></p>
<p>SimpleLisp compiled with jkit, with my LICM optimisation stage:<br />
<code><br />
$ time java org/simplelisp/interpreter/Interpreter examples/Fibonacci.sl<br />
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393</p>
<p>real    0m4.289s<br />
user    0m4.136s<br />
sys     0m0.051s<br />
</code></p>
<p>Something is not quite right here&#8230;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/purejava.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/purejava.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=43&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/08/21/you-are-doing-it-wrong/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
		<item>
		<title>More tests</title>
		<link>http://purejava.wordpress.com/2008/08/21/more-tests/</link>
		<comments>http://purejava.wordpress.com/2008/08/21/more-tests/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 02:24:27 +0000</pubDate>
		<dc:creator>qwandor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[HotSpot]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://purejava.wordpress.com/?p=41</guid>
		<description><![CDATA[Following my tests a couple of days ago and the ensuing discussion, I have done some further testing to better understand what the HotSpot optimiser in the Sun Java VM can do.
In particular, I made an interface called CollectionInterface which my TestCollection class adheres to, and made the test program use that instead of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=41&subd=purejava&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Following <a href="http://purejava.wordpress.com/2008/08/19/testing-manual-optimisation/">my tests a couple of days ago</a> and the ensuing discussion, I have done some further testing to better understand what the HotSpot optimiser in the Sun Java VM can do.</p>
<p>In particular, I made an interface called <tt>CollectionInterface</tt> which my <tt>TestCollection</tt> class adheres to, and made the test program use that instead of the class type. This means that HotSpot does not have enough static type information to inline method calls on the <tt>TestCollection</tt> class (or whatever it was doing with them), and so the manually factored loop is significantly faster than the normal one.</p>
<p>Here is my test program now:<br />
<code><br />
public class ManualMethod {<br />
	public static void main(String[] args) {<br />
		TestCollection list = new TestCollection(1000000000);</p>
<p>		long normalTime = test(list);<br />
		long normalTime2 = test(list);<br />
		long normalTime3 = test(list);<br />
		long factoredTime = testFactored(list);<br />
		long factoredTime2 = testFactored(list);<br />
		long factoredTime3 = testFactored(list);</p>
<p>		System.out.println("Normal: " + normalTime + " ms");<br />
		System.out.println("Normal: " + normalTime2 + " ms");<br />
		System.out.println("Normal: " + normalTime3 + " ms");<br />
		System.out.println("Factored: " + factoredTime + " ms");<br />
		System.out.println("Factored: " + factoredTime2 + " ms");<br />
		System.out.println("Factored: " + factoredTime3 + " ms");<br />
		System.out.println("Side effects: " + list.sideEffects);<br />
	}</p>
<p>	private static long test(CollectionInterface list) {<br />
		long startTime = System.currentTimeMillis();<br />
		for (int i = 0; i &lt; list.size(); ++i) {<br />
		}<br />
		return System.currentTimeMillis() - startTime;<br />
	}</p>
<p>	private static long testFactored(CollectionInterface list) {<br />
		int length = list.size();<br />
		long startTime = System.currentTimeMillis();<br />
		for (int i = 0; i &lt; length; ++i) {<br />
		}<br />
		return System.currentTimeMillis() - startTime;<br />
	}<br />
}<br />
</code><br />
And the output:<br />
<code><br />
$ java ManualMethod<br />
Normal: 2192 ms<br />
Normal: 2182 ms<br />
Normal: 2204 ms<br />
Factored: 737 ms<br />
Factored: 727 ms<br />
Factored: 885 ms<br />
Side effects: 0<br />
</code><br />
With the server VM, the effect is now even more pronounced:<br />
<code><br />
$ java -server ManualMethod<br />
Normal: 1458 ms<br />
Normal: 1451 ms<br />
Normal: 1445 ms<br />
Factored: 1 ms<br />
Factored: 0 ms<br />
Factored: 0 ms<br />
Side effects: 0<br />
</code><br />
Presumable here the server VM can completely remove the loop in the factored case as it is not producing any useful results, but it cannot know whether the call to <tt>CollectionInterface.size()</tt> will have side effects so cannot remove the loop in the case that calls that on every iteration.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/purejava.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/purejava.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/purejava.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/purejava.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/purejava.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/purejava.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/purejava.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/purejava.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/purejava.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/purejava.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/purejava.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/purejava.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=purejava.wordpress.com&blog=3275278&post=41&subd=purejava&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://purejava.wordpress.com/2008/08/21/more-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5699ac4e633bf5edbd9b7fca16e2a5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">qwandor</media:title>
		</media:content>
	</item>
	</channel>
</rss>