[Haskell-beginners] Cost center annotations - where/let difference

Daniel Seidel ds at iai.uni-bonn.de
Thu Nov 18 05:24:24 EST 2010


Hi,

I was doing some heap profiles and ran into the following issue.

Consider the program fib.hs:

module Main where

fib i | i == 0 || i == 1 = 1
      | i > 1            = fib (i-1) + fib (i-2)
      | otherwise        = 0

testWhere = {-# SCC "Where" #-} res
  where res = fib 35

testLet = {-# SCC "Let" #-}
          let res = fib 35
          in res

If I choose 

main = print testLet

compile with: ghc --make -prof -auto-all -caf-all -O2 fib.hs
and run:      ./fib +RTS -hc -hCLet -L60

the fib.hp file will contain entries as expected.

If I choose

main = print testWhere

compile with: ghc --make -prof -auto-all -caf-all -O2 fib.hs
and run:      ./fib +RTS -hc -hCWhere -L60

the fib.hp file will contain the timestamps, but entries for measured
heap consumption.

Can anyone please tell me, if this is the expected behavior? I'm not
very experienced in benchmarking and was a bit irritated by that
difference.

Cheers, Daniel.




More information about the Beginners mailing list