[Haskell-cafe] Fannkuch Entry

David F. Place d at vidplace.com
Fri Jan 6 11:27:24 EST 2006


Hi All,

I've been enjoying following the thread about the "shootout" programs  
and trying to understand the performance of the entries, especially  
the Fannkuch benchmark.  I've been comparing Sebastion's and  
Bertram's proposals found on the wiki.   On my machine (PowerBook g4  
(512M), GHC 6.4.1), Bertam's is about 3x faster. I think the main  
reason for the difference is that Bertram's conses much less and  
keeps much less data live on the heap.

I don't find Bertram's version especially hard to read.  I tripped on  
'>>=', but it was easy to look it up.  You can substitute "concatMap"  
without penalty if you hate monads.  The technique used in Bertram's  
`flop' is known to anyone who has been introduced to streams.

I think Bertram solution is an idiomatic "engineered" Haskell program.

Cheers, David

-------------------------------------------------
[Marcel:~/pfann] david% time ./Sebastion 9
123456789
...
Pfannkuchen(9) = 30
8.132u 0.250s 0:08.89 94.2%     0+0k 0+2io 0pf+0w
-------------------------------------------------
[Marcel:~/pfann] david% time ./Bertram 9
123456789
...
Pfannkuchen(9) = 30
2.629u 0.100s 0:03.10 87.7%     0+0k 0+4io 0pf+0w
-------------------------------------------------

-------------------------------------------------
./Sebastion 9 +RTS -K256m -c -sstderr
123456789
...
Pfannkuchen(9) = 30
911,697,700 bytes allocated in the heap
   3,138,348 bytes copied during GC
       5,172 bytes maximum residency (2 sample(s))

        3478 collections in generation 0 (  0.28s)
           2 collections in generation 1 (  0.01s)

           2 Mb total memory in use

   INIT  time    0.00s  (  0.00s elapsed)
   MUT   time    7.85s  (  8.52s elapsed)
   GC    time    0.29s  (  0.44s elapsed)
   EXIT  time    0.00s  (  0.00s elapsed)
   Total time    8.14s  (  8.96s elapsed)

   %GC time       3.6%  (4.9% elapsed)

   Alloc rate    116,139,834 bytes per MUT second

   Productivity  96.4% of total user, 87.6% of total elapsed
-------------------------------------------------
./Bertram 9 +RTS -K256m -c -sstderr
123456789
...
Pfannkuchen(9) = 30
271,671,720 bytes allocated in the heap
     818,676 bytes copied during GC
       5,220 bytes maximum residency (1 sample(s))

        1036 collections in generation 0 (  0.08s)
           1 collections in generation 1 (  0.00s)

           1 Mb total memory in use

   INIT  time    0.00s  (  0.01s elapsed)
   MUT   time    2.56s  (  2.90s elapsed)
   GC    time    0.08s  (  0.09s elapsed)
   EXIT  time    0.00s  (  0.00s elapsed)
   Total time    2.64s  (  3.00s elapsed)

   %GC time       3.0%  (3.0% elapsed)

   Alloc rate    106,121,765 bytes per MUT second

   Productivity  97.0% of total user, 85.3% of total elapsed

------------------------------------------------------



--------------------------------
David F. Place
mailto:d at vidplace.com



More information about the Haskell-Cafe mailing list