module Test.SBench.Space.Single.ExploreProfile ( getMaxMem , getMemLine ) where import Profiling.Heap.Read ( readProfile ) import Profiling.Heap.Types ( Profile(..), ProfileQuery(..), ProfileSample) getMaxMem :: FilePath -> IO Integer getMaxMem fp = do prof <- myReadProfile fp return $ (fromIntegral (maxCost prof) :: Integer) getMemLine :: FilePath -> IO [(Double, Integer)] getMemLine fp = do prof <- myReadProfile fp let s = samples prof return $ map (\(t, xs) -> (t, getCost xs)) s myReadProfile :: FilePath -> IO Profile myReadProfile fp = do mprof <- readProfile fp case mprof of Nothing -> error $ "could not read " ++ fp Just prof -> return $ prof getCost :: ProfileSample -> Integer getCost = sum . map (fromIntegral . snd)