Skip to content

Commit 5c0edf2

Browse files
committed
Fix render of heap profiles in -p mode
Fixes #191
1 parent 7f8e9ff commit 5c0edf2

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/Eventlog/Data.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ generateJsonData a (ProfData h binfo ccMap fs traces heap_info ipes _ticky_count
4040
sortBy (flip (comparing (fst . snd))) $ Map.toList keeps
4141
-- Only supply the cost centre view in cost centre profiling mode.
4242
cc_descs = case hHeapProfileType h of
43-
Just HeapProfBreakdownCostCentre -> Just (outputTree ccMap mdescs)
43+
(FromEventlog (Just HeapProfBreakdownCostCentre)) -> Just (outputTree ccMap mdescs)
4444
_ -> Nothing
4545

4646
use_ipes = case hHeapProfileType h of
47-
Just HeapProfBreakdownInfoTable -> Just ipes
47+
(FromEventlog (Just HeapProfBreakdownInfoTable)) -> Just ipes
4848
_ -> Nothing
4949

5050
-- If we have IPE info, try to translate info table pointers to names

src/Eventlog/Events.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ elHeader EL{..} =
344344
let title = maybe "" T.unwords pargs
345345
date = formatDate clocktimeSec
346346
ppSamplingRate = T.pack . maybe "<Not available>" (show . fromNano) $ samplingRate
347-
in \v -> Header title date heapProfileType ppSamplingRate "" "" v (T.unpack . head <$> pargs)
347+
in \v -> Header title date (FromEventlog heapProfileType) ppSamplingRate "" "" v (T.unpack . head <$> pargs)
348348

349349

350350
elBucketMap :: EL -> BucketMap

src/Eventlog/HeapProf.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ chunkT s =
2727
[job, date, smpU, valU] =
2828
zipWith header [sJOB, sDATE, sSAMPLE_UNIT, sVALUE_UNIT] hs
2929
fs = chunkSamples ss
30-
in (\v -> Header job date Nothing (pack "") smpU valU v Nothing
30+
in (\v -> Header job date FromHPFile (pack "") smpU valU v Nothing
3131
, fs
3232
)
3333

src/Eventlog/HtmlTemplate.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Data.FileEmbed
1919
import Eventlog.Data
2020
import Eventlog.Javascript
2121
import Eventlog.Args
22-
import Eventlog.Types (Header(..), HeapProfBreakdown(..))
22+
import Eventlog.Types (Header(..), HeapProfBreakdown(..), ProfileType(..))
2323
import Eventlog.Rendering.Bootstrap
2424
import Eventlog.Rendering.Types
2525
import Eventlog.VegaTemplate
@@ -162,11 +162,15 @@ perTabFooter :: Header -> Html
162162
perTabFooter header' = do
163163
H.div ! class_ "row" $ do
164164
H.div ! class_ "col" $ do
165-
toHtml $ maybe "No heap profile" ppHeapProfileType (hHeapProfileType header')
165+
toHtml $ render_type (hHeapProfileType header')
166166
", created at "
167167
code $ toHtml $ hDate header'
168168
" by "
169169
code $ toHtml $ hJob header'
170+
where
171+
render_type FromHPFile = "heap profile"
172+
render_type (FromEventlog Nothing) = "No heap profile"
173+
render_type (FromEventlog (Just t)) = ppHeapProfileType t
170174

171175

172176
select_data :: IncludeTraceData -> ChartType -> [Text]
@@ -248,7 +252,11 @@ metaTab header' _as =
248252
" seconds between heap samples"
249253

250254
has_heap_profile :: Header -> Bool
251-
has_heap_profile h = isJust (hHeapProfileType h)
255+
has_heap_profile h =
256+
case (hHeapProfileType h) of
257+
FromHPFile -> True
258+
FromEventlog t -> isJust t
259+
252260

253261
allHeapTabs :: Header -> Args -> HeapProfileData -> [TabGroup]
254262
allHeapTabs header' as x =

src/Eventlog/Types.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ data Header =
1919
Header
2020
{ hJob :: Text
2121
, hDate :: Text
22-
, hHeapProfileType :: Maybe HeapProfBreakdown
22+
, hHeapProfileType :: ProfileType
2323
, hSamplingRate :: Text
2424
, hSampleUnit :: Text
2525
, hValueUnit :: Text
2626
, hCount :: Int
2727
, hProgPath :: Maybe FilePath
2828
} deriving Show
2929

30+
data ProfileType = FromHPFile | FromEventlog (Maybe HeapProfBreakdown) deriving Show
31+
3032

3133
-- The bucket is a key to uniquely identify a band
3234
newtype Bucket = Bucket Text

0 commit comments

Comments
 (0)