<?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>Inadvertent incorrectness &#187; O&#8217;Caml</title>
	<atom:link href="http://ken.friislarsen.net/blog/category/coding/ocaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://ken.friislarsen.net/blog</link>
	<description>... but that doesn&#039;t matter, because I turn it into a sexy dance</description>
	<lastBuildDate>Thu, 29 Sep 2011 12:16:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A hand full of Queens</title>
		<link>http://ken.friislarsen.net/blog/2004/08/31/a-hand-full-of-queens/</link>
		<comments>http://ken.friislarsen.net/blog/2004/08/31/a-hand-full-of-queens/#comments</comments>
		<pubDate>Tue, 31 Aug 2004 21:52:03 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[O'Caml]]></category>
		<category><![CDATA[SML]]></category>

		<guid isPermaLink="false">http://ken.friislarsen.net/blog/?p=8</guid>
		<description><![CDATA[Or: SML/Moscow ML is faster than C++/GCC Inspired by a remark by Peter about the abysmal performance of exceptions on the .NET platform. I decided to check it for myself with a micro-benchmark. I also decided to check the performance &#8230; <a href="http://ken.friislarsen.net/blog/2004/08/31/a-hand-full-of-queens/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Or: <b>SML/Moscow ML is faster than C++/GCC</b></p>
<p>Inspired by a remark by <a href="http://www.dina.dk/~sestoft">Peter</a> about the abysmal performance of exceptions on the .NET platform.  I decided to check it for myself with a micro-benchmark. I also decided to check the performance of C++ exceptions, just for the fun of it.</p>
<p>The micro-benchmark is to find a solution to the N-queen problem using backtracking, with exceptions used as backtracking. I tested four different languages (SML, O&#8217;Caml, C#, and C++) and five different language implementations (<a href="http://mlton.org">MLton</a>, <a href="http://www.dina.dk/~sestoft/mosml.html">Moscow ML</a>, <a href="http://caml.inria.fr/ocaml">O&#8217;Caml</a>, <a href="http://mono-project.com">Mono</a>, and <a href="http://gcc.gnu.org/">GCC</a>). The results are a bit surprising, and definately deserves further investigation. The graph below shows the running times for the five different executables:</p>
<p align="center"><a href="http://ken.friislarsen.net/blog/images/queens-graph.png"><img src="http://ken.friislarsen.net/blog/images/queens-graph-small.png" alt="Graph showing running times for the different executables"/></a></p>
<p>From the graph we see that O&#8217;Caml and MLton are way faster than the rest (and O&#8217;Caml has a small edge compared to MLton), Moscow ML is faster than Mono, and my C++ program is slow as a slug. I&#8217;ve tried various small tweaks to make the C++ version faster, but nothing really helps. For instance, at first we might notice that there are a tiny algorithmic difference between the C++ version and the other versions, namely the order in which a new position is compared with the already determined positions. But changing this order have no real effect (I&#8217;ve tried to change C++ program in various ways, and I tried to change the other programs). Still, the C++ performance is so bad that it looks suspicious. I&#8217;m open to suggestions for how to improve the C++ program.</p>
<p>Now I just have to test the SML version with the MLKit and SML/NJ, test the C# version with Microsoft&#8217;s runtime, test the C++ version with Visual C++ and Intel&#8217;s C++ compiler, and make a Java version of the benchmark and test it with &#8230;  Any volunteers?
</p>
<p>The programs used in the benchmark are here: <a href="http://ken.friislarsen.net/blog/images/queens.sml">queens.sml</a>, <a href="http://ken.friislarsen.net/blog/images/queens.ml">queens.ml</a>, <a href="http://ken.friislarsen.net/blog/images/queens.cs">queens.cs</a> (ran <code>mono</code> with option <code>--optimize=all</code>) , and <a href="http://ken.friislarsen.net/blog/images/queens.cpp">queens.cpp</a> (compiled with option <code>-O3</code>).</p>
]]></content:encoded>
			<wfw:commentRss>http://ken.friislarsen.net/blog/2004/08/31/a-hand-full-of-queens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

