
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@73rus.com, http://vss.73rus.com

On Thu, Aug 28, 2008 at 3:37 PM, Vlad Skvortsov
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?
You need more SCC annotations.
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.
Are you sure? Lazy evaluation is tricky. Try adding an SCC annotation to each function. E.g.:
dumpWith f = {-# SCC 'fold' #-} Data.Map.foldWithKey f [] docToStr k (Doc { docName=n, docVectorLength=vl}) = {-# SCC 'docToStr' #-} (:) ("d " ++ show k ++ " " ++ n ++ " " ++ (show vl))
The call stack will then help you determine which invocation of the given function is taking up the time. Or it may be somewhere else. The Real World Haskell chapter on profiling is a good guide: http://book.realworldhaskell.org/beta/profiling.html Justin
participants (2)
-
Justin Bailey
-
Vlad Skvortsov