Cost centers are annotations on a Haskell program which can be added automatically by the GHC compiler -- using -fprot-auto
-- or by a programmer using {-# SCC "name" #-} <expression>
, where "name" is any name you wish and <expression>
is any valid Haskell expression:
-- Main.hs
main :: IO ()
main = do let l = [1..9999999]
print $ {-# SCC "print_list" #-} (length l)
Compiling with -fprof
and running with +RTS -p
e.g. ghc -prof -rtsopts Main.hs && ./Main.hs +RTS -p
would produce Main.prof
once the program's exited.