module GHC.Prof.Types where
import Data.Monoid
import Prelude
import Data.IntMap (IntMap)
import Data.Map (Map)
import Data.Scientific (Scientific)
import Data.Sequence (Seq)
import Data.Text (Text)
import Data.Time (DiffTime, LocalTime)
data Profile = Profile
{ profileTimestamp :: !LocalTime
, profileCommandLine :: !Text
, profileTotalTime :: !TotalTime
, profileTotalAlloc :: !TotalAlloc
, profileTopCostCentres :: [AggregateCostCentre]
, profileCostCentreTree :: !CostCentreTree
} deriving Show
data TotalTime = TotalTime
{ totalTimeElapsed :: !DiffTime
, totalTimeTicks :: !Integer
, totalTimeResolution :: !DiffTime
, totalTimeProcessors :: !Int
} deriving Show
newtype TotalAlloc = TotalAlloc
{ totalAllocBytes :: Integer
} deriving Show
data AggregateCostCentre = AggregateCostCentre
{ aggregateCostCentreName :: !Text
, aggregateCostCentreModule :: !Text
, aggregateCostCentreSrc :: !(Maybe Text)
, aggregateCostCentreTime :: !Scientific
, aggregateCostCentreAlloc :: !Scientific
, aggregateCostCentreTicks :: !(Maybe Integer)
, aggregateCostCentreBytes :: !(Maybe Integer)
} deriving Show
data CostCentre = CostCentre
{ costCentreName :: !Text
, costCentreModule :: !Text
, costCentreSrc :: !(Maybe Text)
, costCentreNo :: !CostCentreNo
, costCentreEntries :: !Integer
, costCentreIndTime :: !Scientific
, costCentreIndAlloc :: !Scientific
, costCentreInhTime :: !Scientific
, costCentreInhAlloc :: !Scientific
, costCentreTicks :: !(Maybe Integer)
, costCentreBytes :: !(Maybe Integer)
} deriving Show
type CostCentreNo = Int
data CostCentreTree = CostCentreTree
{ costCentreNodes :: !(IntMap CostCentre)
, costCentreParents :: !(IntMap CostCentreNo)
, costCentreChildren :: !(IntMap (Seq CostCentre))
, costCentreCallSites :: !(Map (Text, Text) (Seq CostCentre))
, costCentreAggregate :: !(Map (Text, Text) AggregateCostCentre)
} deriving Show
emptyCostCentreTree :: CostCentreTree
emptyCostCentreTree = CostCentreTree
{ costCentreNodes = mempty
, costCentreParents = mempty
, costCentreChildren = mempty
, costCentreCallSites = mempty
, costCentreAggregate = mempty
}
data Callee = Callee
{ calleeName :: Text
, calleeModule :: Text
, calleeEntries :: !Integer
, calleeTime :: !Scientific
, calleeAlloc :: !Scientific
, calleeTicks :: !(Maybe Integer)
, calleeBytes :: !(Maybe Integer)
} deriving Show
data CallSite = CallSite
{ callSiteCostCentre :: CostCentre
, callSiteContribEntries :: !Integer
, callSiteContribTime :: !Scientific
, callSiteContribAlloc :: !Scientific
, callSiteContribTicks :: !(Maybe Integer)
, callSiteContribBytes :: !(Maybe Integer)
} deriving Show