<?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"
	>
<channel>
	<title>Comments on: More on Fibonacci. Oops, Sorry Lisp&#8230; Haskell runs it 5 times faster</title>
	<atom:link href="http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/feed/" rel="self" type="application/rss+xml" />
	<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/</link>
	<description>By Antonio Cangiano, Software Engineer &#38; Technical Evangelist at IBM</description>
	<pubDate>Sat, 19 Jul 2008 23:51:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Muha</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-3522</link>
		<dc:creator>Muha</dc:creator>
		<pubDate>Thu, 24 Apr 2008 18:43:26 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-3522</guid>
		<description>Fastest:
&lt;br/&gt;
&lt;pre&gt;
import Control.Monad
import Text.Printf

fibs :: [Integer]
fibs = 0:1:zipWith (+) fibs (tail fibs)

fib n = fibs !! n

main = forM_ [0..45] $ \i -&#62; printf "n=%d =&#62; %d\n" i (fib i)
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Fastest:<br />
</p>
<pre>
import Control.Monad
import Text.Printf

fibs :: [Integer]
fibs = 0:1:zipWith (+) fibs (tail fibs)

fib n = fibs !! n

main = forM_ [0..45] $ \i -&gt; printf &#8220;n=%d =&gt; %d\n&#8221; i (fib i)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Isaac Gouy</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2182</link>
		<dc:creator>Isaac Gouy</dc:creator>
		<pubDate>Mon, 07 Jan 2008 15:37:30 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2182</guid>
		<description>Geir Aalberg wrote
&#62; this comparative test between SBCL Lisp and GHC Haskell

And note all those SBCL "due to type uncertainty" warnings.</description>
		<content:encoded><![CDATA[<p>Geir Aalberg wrote<br />
&gt; this comparative test between SBCL Lisp and GHC Haskell</p>
<p>And note all those SBCL &#8220;due to type uncertainty&#8221; warnings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geir Aalberg</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2090</link>
		<dc:creator>Geir Aalberg</dc:creator>
		<pubDate>Thu, 03 Jan 2008 03:18:28 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2090</guid>
		<description>You might also find this comparative test between SBCL Lisp and GHC Haskell useful. The "recursive" test does a series of recursive computations including Fibonacci, and here SBCL is only 20 % slower:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&#38;lang=sbcl&#38;lang2=ghc

Also, note the wise words on the front page:

"How can we benchmark a programming language?
We can't - we benchmark programming language implementations.
How can we benchmark language implementations?
We can't - we measure particular programs."</description>
		<content:encoded><![CDATA[<p>You might also find this comparative test between SBCL Lisp and GHC Haskell useful. The &#8220;recursive&#8221; test does a series of recursive computations including Fibonacci, and here SBCL is only 20 % slower:</p>
<p><a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&amp;lang=sbcl&amp;lang2=ghc" rel="nofollow">http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&amp;lang=sbcl&amp;lang2=ghc</a></p>
<p>Also, note the wise words on the front page:</p>
<p>&#8220;How can we benchmark a programming language?<br />
We can&#8217;t - we benchmark programming language implementations.<br />
How can we benchmark language implementations?<br />
We can&#8217;t - we measure particular programs.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Hansen</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1948</link>
		<dc:creator>Mike Hansen</dc:creator>
		<pubDate>Wed, 26 Dec 2007 04:05:56 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1948</guid>
		<description>This nice thing about Python is that it has Cython ( http://www.cython.org ).  The original Python code took 131s on my machine.  The following is the conversion of that code to Cython:

cdef fib(int n):
   if n == 0 or n == 1:
      return n
   else:
      return fib(n-1) + fib(n-2)

def test(n):
    for i in range(n):
        print "n=%d =&#62; %d" % (i, fib(i))

This code runs in 2.08 CPU seconds on my machine.</description>
		<content:encoded><![CDATA[<p>This nice thing about Python is that it has Cython ( <a href="http://www.cython.org" rel="nofollow">http://www.cython.org</a> ).  The original Python code took 131s on my machine.  The following is the conversion of that code to Cython:</p>
<p>cdef fib(int n):<br />
   if n == 0 or n == 1:<br />
      return n<br />
   else:<br />
      return fib(n-1) + fib(n-2)</p>
<p>def test(n):<br />
    for i in range(n):<br />
        print &#8220;n=%d =&gt; %d&#8221; % (i, fib(i))</p>
<p>This code runs in 2.08 CPU seconds on my machine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geir Aalberg</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1678</link>
		<dc:creator>Geir Aalberg</dc:creator>
		<pubDate>Fri, 14 Dec 2007 16:11:57 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1678</guid>
		<description>Guys,

for precise benchmarking you should turn always off I/O during iterations. Running under clisp on my MacBook Pro (same config as yours), the recursive Fibonacci test takes 0.005539 sec for n=45, while turning off the call to the actual computation reduces it to 0.003004 sec, i.e. only a 45 % reduction in cpu time.

Granted, some of this is startup overhead, but commenting out the format statement gives only a run time of 0.000125 sec, so unless it's smart enough to optimize out those function calls this can be neglected.</description>
		<content:encoded><![CDATA[<p>Guys,</p>
<p>for precise benchmarking you should turn always off I/O during iterations. Running under clisp on my MacBook Pro (same config as yours), the recursive Fibonacci test takes 0.005539 sec for n=45, while turning off the call to the actual computation reduces it to 0.003004 sec, i.e. only a 45 % reduction in cpu time.</p>
<p>Granted, some of this is startup overhead, but commenting out the format statement gives only a run time of 0.000125 sec, so unless it&#8217;s smart enough to optimize out those function calls this can be neglected.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Adkins</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1552</link>
		<dc:creator>Brian Adkins</dc:creator>
		<pubDate>Sat, 01 Dec 2007 18:32:28 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1552</guid>
		<description>Compiling the Haskell code with optimizations made a *huge* difference. The fastest of several runs w/o optimization was 6.552s and with optimization was 0.860s. With that, the Lisp code took 1.8 times as long to execute.

Either one of those blows away Ruby which is what I typically code in. It took 95s :)</description>
		<content:encoded><![CDATA[<p>Compiling the Haskell code with optimizations made a *huge* difference. The fastest of several runs w/o optimization was 6.552s and with optimization was 0.860s. With that, the Lisp code took 1.8 times as long to execute.</p>
<p>Either one of those blows away Ruby which is what I typically code in. It took 95s <img src='http://antoniocangiano.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio Cangiano</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1548</link>
		<dc:creator>Antonio Cangiano</dc:creator>
		<pubDate>Sat, 01 Dec 2007 09:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1548</guid>
		<description>Ahah, that's cool w-g. With all the optimizations on, and using Valentino's optimized version, I can see that Lisp is &lt;b&gt;very&lt;/b&gt; fast. That's very good. We knew already that the main compilers for Lisp and Haskell were very fast, just like OCaml and F# are too. But establishing which one is faster and for what applications, is beyond the reach of our silly test. :)</description>
		<content:encoded><![CDATA[<p>Ahah, that&#8217;s cool w-g. With all the optimizations on, and using Valentino&#8217;s optimized version, I can see that Lisp is <b>very</b> fast. That&#8217;s very good. We knew already that the main compilers for Lisp and Haskell were very fast, just like OCaml and F# are too. But establishing which one is faster and for what applications, is beyond the reach of our silly test. <img src='http://antoniocangiano.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: w-g</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1547</link>
		<dc:creator>w-g</dc:creator>
		<pubDate>Sat, 01 Dec 2007 08:44:53 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1547</guid>
		<description>For both non-tail-recursive versions:

Haskell (ghc with -O2):
real    3m7.850s (187.85s)
user    2m23.953s (143.95s)
sys     0m1.188s


Lisp (GCL with optimization turned on):
real time       :    137.860 secs
run-gbc time    :    117.470 secs
child run time  :      0.000 secs
gbc time        :      0.000 secs

"Sorry Haskell..."</description>
		<content:encoded><![CDATA[<p>For both non-tail-recursive versions:</p>
<p>Haskell (ghc with -O2):<br />
real    3m7.850s (187.85s)<br />
user    2m23.953s (143.95s)<br />
sys     0m1.188s</p>
<p>Lisp (GCL with optimization turned on):<br />
real time       :    137.860 secs<br />
run-gbc time    :    117.470 secs<br />
child run time  :      0.000 secs<br />
gbc time        :      0.000 secs</p>
<p>&#8220;Sorry Haskell&#8230;&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: w-g</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1545</link>
		<dc:creator>w-g</dc:creator>
		<pubDate>Sat, 01 Dec 2007 01:04:19 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1545</guid>
		<description>- Include type declarations
- Set optimizations on
- Compile the functions using a fast Lisp compiler (SBCL or CMUCL)

- If you use CMUCL, then use block compilation


I tried both on my machine, and Lisp was several times faster.</description>
		<content:encoded><![CDATA[<p>- Include type declarations<br />
- Set optimizations on<br />
- Compile the functions using a fast Lisp compiler (SBCL or CMUCL)</p>
<p>- If you use CMUCL, then use block compilation</p>
<p>I tried both on my machine, and Lisp was several times faster.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio Cangiano</title>
		<link>http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1544</link>
		<dc:creator>Antonio Cangiano</dc:creator>
		<pubDate>Sat, 01 Dec 2007 00:28:42 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1544</guid>
		<description>Valentino wrote: 
&gt; Common Lisp is a wonderful wonderful language IMHO.

On this we entirely agree, and it's fast too. Mine was a tongue in cheek reply to the Lisper who wrongly compared apples and oranges. :)</description>
		<content:encoded><![CDATA[<p>Valentino wrote:<br />
> Common Lisp is a wonderful wonderful language IMHO.</p>
<p>On this we entirely agree, and it&#8217;s fast too. Mine was a tongue in cheek reply to the Lisper who wrongly compared apples and oranges. <img src='http://antoniocangiano.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
