[Haskell-cafe] The Computer Language Benchmarks Game: pidigits

Arnaud Payement arnaud.payement at gmail.com
Mon May 25 16:18:29 EDT 2009



It is quite hard for me to tell why this entry is faster than the one one as I used the C entry as a starting point which I then refactored multiple times to ensure that the solution is closer to what one who right in Haskell.
The only big difference I can see between the two is the different usage of list comprehension. The preceding entry was building a list which is then refined using the str method to end up being the list of digits. On the other hand my version use list continuation to recursively build a list of (digit, state) and then you simply have to print (map fst (tail digits)).
I did not use the strictness annotations because they did not improve the performance when I tried to add them and I thought it is better to show Haskell as one would naturally write it. 

  ----- Original Message ----- 
  From: Alberto G. Corona 
  To: Arnaud Payement ; haskell-cafe at haskell.org 
  Sent: Monday, May 25, 2009 10:54 AM
  Subject: Re: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits


  > :
  > > By the way, I did submit my solution. It improved the score a bit but it
  > > is still very memory hungry.

   a bit?
  Currentlly it is the fastest  in 32 bit . the memory/speed problems happens in 64 bit benchmarks. I suppose that the speed is related with the memory leak that will be fixed, Dons said.  Event there doubled the performance of the previous entry.  


  Just to learn; how this last version is faster than the previous entry?  This new version does not use strictness annotations. Is this an example where laziness pays (and indeed causes the memory leak in the 64 bit architectures?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090525/254e0975/attachment.html


More information about the Haskell-Cafe mailing list