packages feed

ghc-time-alloc-prof 0.0.0 → 0.0.0.1

raw patch · 5 files changed

+39/−19 lines, 5 files

Files

bin/dump.hs view
@@ -16,16 +16,17 @@ main = do   file:restArgs <- getArgs   text <- TLIO.readFile file-  let ATL.Done _ prof = ATL.parse timeAllocProfile text-  case restArgs of-    [] -> Fold.mapM_ putStrLn $ drawTree . fmap makeCCName <$> profileCostCentres prof-    name:modName:_ -> do-      case profileCallSites (T.pack name) (T.pack modName) prof of-        Nothing -> putStrLn "failed to parse call sites"-        Just (callee, callSites) -> do-          print callee-          Fold.mapM_ print callSites-    _ -> fail "Invalid parameters"+  case ATL.parse timeAllocProfile text of+    ATL.Fail unconsumed contexts reason -> fail $ show (unconsumed, contexts, reason)+    ATL.Done _ prof -> case restArgs of+      [] -> Fold.mapM_ putStrLn $ drawTree . fmap makeCCName <$> profileCostCentres prof+      name:modName:_ -> do+        case profileCallSites (T.pack name) (T.pack modName) prof of+          Nothing -> putStrLn "failed to parse call sites"+          Just (callee, callSites) -> do+            print callee+            Fold.mapM_ print callSites+      _ -> fail "Invalid parameters"  makeCCName :: CostCentre -> String makeCCName cc = T.unpack (costCentreModule cc)@@ -42,4 +43,3 @@   ++ ","   ++ show (costCentreIndAlloc cc)   ++ ")"-
ghc-time-alloc-prof.cabal view
@@ -1,5 +1,5 @@ name: ghc-time-alloc-prof-version: 0.0.0+version: 0.0.0.1 synopsis: Library for parsing GHC time and allocation profiling reports description: Library for parsing GHC time and allocation profiling reports homepage: https://github.com/maoe/ghc-time-alloc-prof
src/GHC/RTS/TimeAllocProfile/CostCentreTree.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} module GHC.RTS.TimeAllocProfile.CostCentreTree   ( profileCostCentres@@ -20,12 +21,18 @@ import Data.Tree (Tree) import Prelude hiding (mapM) import qualified Data.Foldable as Fold-import qualified Data.IntMap.Strict as IntMap-import qualified Data.Map.Strict as Map import qualified Data.Sequence as Seq import qualified Data.Tree as Tree  import GHC.RTS.TimeAllocProfile.Types++#if MIN_VERSION_containers(0, 5, 0)+import qualified Data.IntMap.Strict as IntMap+import qualified Data.Map.Strict as Map+#else+import qualified Data.IntMap as IntMap+import qualified Data.Map as Map+#endif  -- | Build a tree of cost-centres from a profiling report. profileCostCentres :: TimeAllocProfile -> Maybe (Tree CostCentre)
src/GHC/RTS/TimeAllocProfile/Parser.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE MultiWayIf #-} module GHC.RTS.TimeAllocProfile.Parser   ( timeAllocProfile @@ -22,14 +22,20 @@ import Data.Sequence (Seq, (><), (|>)) import Data.Text (Text) import Data.Time-import qualified Data.IntMap.Strict as IntMap-import qualified Data.Map.Strict as Map import qualified Data.Sequence as Seq  import Data.Attoparsec.Text as A  import GHC.RTS.TimeAllocProfile.Types +#if MIN_VERSION_containers(0, 5, 0)+import qualified Data.IntMap.Strict as IntMap+import qualified Data.Map.Strict as Map+#else+import qualified Data.IntMap as IntMap+import qualified Data.Map as Map+#endif+ timeAllocProfile :: Parser TimeAllocProfile timeAllocProfile = do   skipSpace@@ -122,6 +128,7 @@ briefCostCentre = BriefCostCentre   <$> symbol <* skipSpace -- name   <*> symbol <* skipSpace -- module+  <*> optional symbol <* skipSpace -- src   <*> double <* skipSpace -- %time   <*> double <* skipSpace -- %alloc   <*> optional decimal <* skipSpace -- ticks@@ -134,8 +141,9 @@  costCentre :: Parser CostCentre costCentre = do-  name <- A.takeWhile (not . isSpace); skipSpace-  modName <- A.takeWhile (not . isSpace); skipSpace+  name <- symbol; skipSpace+  modName <- symbol; skipSpace+  src <- optional symbol; skipSpace   no <- decimal; skipSpace   entries <- decimal; skipSpace   indTime <- double; skipSpace@@ -146,6 +154,7 @@   return CostCentre     { costCentreName = name     , costCentreModule = modName+    , costCentreSrc = src     , costCentreNo = no     , costCentreEntries = entries     , costCentreIndTime = indTime
src/GHC/RTS/TimeAllocProfile/Types.hs view
@@ -40,6 +40,8 @@   -- ^ Name of the cost-centre   , briefCostCentreModule :: Text   -- ^ Module name of the cost-centre+  , briefCostCentreSrc :: Maybe Text+  -- ^ Source location of the cost-centre   , briefCostCentreTime :: Double   -- ^ Total time spent in the cost-centre   , briefCostCentreAlloc :: Double@@ -58,6 +60,8 @@   -- ^ Name of the cost-centre   , costCentreModule :: Text   -- ^ Module name of the cost-centre+  , costCentreSrc :: Maybe Text+  -- ^ Source location of the cost-centre   , costCentreNo :: CostCentreNo   -- ^ Identifier of the cost-centre   , costCentreEntries :: Integer