1 module Pool(poolGraph) where 2 3 import StdLib 4 import GRIP 5 import PSlib 6 import Graph 7 import Parse 8 9 poolGraph selectpes statFile = 10 initGraph "Spark Pool Profile Graph" (pes,selectpes) (100*ticks,height) 11 ("Time (ms)", "Sparks") [(5,"Spark Residency",""), (0,"Sparks Used","")] 12 ++ scale (my_fromInt dimX/my_fromInt 200) (my_fromInt dimY/my_fromInt height) 13 ++ plotCurve 0 usedGraph 14 ++ plotCurve 5 sparkGraph 15 where 16 (sparkGraph,usedGraph) = outlineGraphs (traces++[T width [0,0,0]]) 17 (pes,ticks,orderedStats) = getParameters stats 18 height = axisScale h 19 stats = parseFile statFile 20 (traces,((sparks,used,resumed),_,h,width)) 21 = akkumulate processSparks nullstate (gatherSp (Sp 0 0 0 0 0) (getSp selectpes orderedStats)) 22 23 24 processSparks ((c'',u'',r''),l'',m,_) (Sp n c u r l) 25 = (T n [p',u',l'], ((c''+c,u''+u,r''+r),l',max m p',n)) 26 where 27 p' = l''+c 28 u' = p'-l 29 l' = p'-u-l 30 31 32 gatherSp t [] = [t] 33 gatherSp t l@(a:as) | numberSp t==numberSp a = gatherSp (addSparks t a) as 34 | otherwise = t:gatherSp (Sp (n+1) 0 0 0 0) l 35 where n=numberSp t 36 37 38 addSparks (Sp _ a b c d) (Sp n a' b' c' d') = Sp n (a+a') (b+b') (c+c') (d+d') 39 40 data Trace = T Int [Int] deriving Show{-was:Text-} 41 42 nullstate = ((0,0,0),0,0,0) 43 44 type Object = [Point] 45 46 outlineGraphs :: [Trace] -> ([Point],[Point]) 47 outlineGraphs traces = aux traces 48 where 49 aux [] = ([],[]) 50 aux (T n [p,u,l]:ts) = (Pt t p:Pt t l:Pt t' l:pas, 51 Pt t u:Pt t' l:pbs) 52 where 53 (pas,pbs) = aux ts 54 t = n*2 55 t' = n*2+1