1{-# LANGUAGE OverloadedStrings #-}
4import qualified Data.Attoparsec.Text as Atto
5import qualified Data.IntMap as IntMap
6import qualified Data.Text as Text
7import qualified Data.Text.IO as Text
8import qualified GHC.RTS.TimeAllocProfile as Prof
9import qualified GHC.RTS.TimeAllocProfile.Types as Prof
10import qualified Text.Tabular as Table
11import qualified Text.Tabular.AsciiArt as Table
17 profToTable "elm-make.prof"
20profToTable :: FilePath -> IO ()
22 do text <- Text.readFile filePath
23 case Atto.parseOnly Prof.timeAllocProfile text of
25 putStrLn $ "Error parsing " ++ filePath ++ ": " ++ err
28 printTable (extractCostCentres profile)
32-- FILTER NAMED COST CENTRES
35extractCostCentres :: Prof.TimeAllocProfile -> [Prof.CostCentre]
36extractCostCentres profile =
39 IntMap.elems (Prof.costCentreNodes (Prof.profileCostCentreTree profile))
41 filter (Text.isPrefixOf "elm_" . Prof.costCentreName) nodes
48printTable :: [Prof.CostCentre] -> IO ()
49printTable costCentres =
52 Table.Group Table.NoLine $
53 map (Table.Header . Text.unpack . Prof.costCentreName) costCentres
56 Table.Table rowHeaders colHeaders (map toRow costCentres)
58 putStrLn (Table.render id id id table)
61colHeaders :: Table.Header String
63 Table.Group Table.NoLine
64 [ Table.Header " total time"
65 , Table.Header " local time"
66 , Table.Header " total alloc"
67 , Table.Header " local alloc"
71toRow :: Prof.CostCentre -> [String]
73 [ show $ Prof.costCentreInhTime costCentre
74 , show $ Prof.costCentreIndTime costCentre
75 , show $ Prof.costCentreInhAlloc costCentre
76 , show $ Prof.costCentreIndAlloc costCentre
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list