[Haskell-beginners] profiling in haskell
Vlad Skvortsov
vss at 73rus.com
Thu Aug 28 18:37:56 EDT 2008
Hi!
I'm trying to profile the code pasted below. Per the profiler output it
takes about 30% of my program running time and I'd like to analyze it
further. What I need is a breakdown on a finer level, so I inserted SCC
annotations. However, they appear to have attributed zero cost. I use
GHC 6.8.2 on FreeBSD, the code is compiled without -O options.
What am I doing wrong?
Note: I'm not trying to *optimize* this code (I intuitively know where
the problems are). My intention is to learn the mechanics of profiling
Haskell code.
serialize :: Database -> [[String]]
serialize (dmap, tmap) =
[
{-# SCC "XXX1" #-} [dbFormatTag],
{-# SCC "XXX2" #-} (dumpWith docToStr dmap),
{-# SCC "XXX3" #-} (dumpWith termToStr tmap)
]
where
dumpWith f = Data.Map.foldWithKey f []
docToStr k (Doc { docName=n, docVectorLength=vl}) =
(:) ("d " ++ show k ++ " " ++ n ++ " " ++ (show vl))
termToStr t il =
(:) ("t " ++ t ++ " " ++ (foldl ilItemToStr "" il))
ilItemToStr acc (docid, weight) =
show docid ++ ":" ++ show weight ++ " " ++ acc
--
Vlad Skvortsov, vss at 73rus.com, http://vss.73rus.com
More information about the Beginners
mailing list