@@ -49,6 +49,7 @@ module Development.Benchmark.Rules
49
49
benchRules , MkBenchRules (.. ), BenchProject (.. ),
50
50
csvRules ,
51
51
svgRules ,
52
+ eventlogRules ,
52
53
allTargets ,
53
54
GetExample (.. ), GetExamples (.. ),
54
55
IsExample (.. ), RuleResultForExample ,
@@ -83,7 +84,7 @@ import GHC.Stack (HasCallStack)
83
84
import qualified Graphics.Rendering.Chart.Backend.Diagrams as E
84
85
import Graphics.Rendering.Chart.Easy ((.=) )
85
86
import qualified Graphics.Rendering.Chart.Easy as E
86
- import System.Directory ( findExecutable , createDirectoryIfMissing )
87
+ import System.Directory ( createDirectoryIfMissing , findExecutable , renameFile )
87
88
import System.FilePath
88
89
import qualified Text.ParserCombinators.ReadP as P
89
90
import Text.Read (Read (.. ), get ,
@@ -134,11 +135,11 @@ allTargets buildFolder = do
134
135
++ [ buildFolder </>
135
136
getExampleName ex </>
136
137
T. unpack (humanName ver) </>
137
- escaped (escapeExperiment e) <.> mode <.> " svg "
138
+ escaped (escapeExperiment e) <.> mode
138
139
| e <- experiments,
139
140
ex <- examples,
140
141
ver <- versions,
141
- mode <- [" " , " diff" ]
142
+ mode <- [" svg " , " diff.svg " , " eventlog.html " ]
142
143
]
143
144
144
145
--------------------------------------------------------------------------------
@@ -188,14 +189,14 @@ buildRules build MkBuildRules{..} = do
188
189
[build -/- " binaries/*/" <> executableName
189
190
,build -/- " binaries/*/ghc.path"
190
191
] &%> \ [out, ghcPath] -> do
191
- let [_, _binaries, _ver , _] = splitDirectories out
192
+ let [_, _binaries, ver , _] = splitDirectories out
192
193
liftIO $ createDirectoryIfMissing True $ dropFileName out
193
194
commitid <- readFile' $ takeDirectory out </> " commitid"
194
- cmd_ $ " git worktree add bench-temp " ++ commitid
195
+ cmd_ $ " git worktree add bench-temp- " ++ ver ++ " " ++ commitid
195
196
buildSystem <- askOracle $ GetBuildSystem ()
196
- flip actionFinally (cmd_ (" git worktree remove bench-temp --force" :: String )) $ do
197
- ghcLoc <- liftIO $ findGhc buildSystem " bench-temp "
198
- buildProject buildSystem [Cwd " bench-temp" ] (" .." </> takeDirectory out)
197
+ flip actionFinally (cmd_ (" git worktree remove bench-temp- " <> ver <> " --force" :: String )) $ do
198
+ ghcLoc <- liftIO $ findGhc buildSystem ver
199
+ buildProject buildSystem [Cwd $ " bench-temp- " <> ver ] (" .." </> takeDirectory out)
199
200
writeFile' ghcPath ghcLoc
200
201
201
202
--------------------------------------------------------------------------------
@@ -224,17 +225,19 @@ benchRules build benchResource MkBenchRules{..} = do
224
225
priority 0 $
225
226
[ build -/- " */*/*.csv" ,
226
227
build -/- " */*/*.benchmark-gcStats" ,
228
+ build -/- " */*/*.eventlog" ,
229
+ build -/- " */*/*.hp" ,
227
230
build -/- " */*/*.log"
228
231
]
229
- &%> \ [outcsv, outGc, outLog] -> do
232
+ &%> \ [outcsv, outGc, outEventLog, outHp, outLog] -> do
230
233
let [_, exampleName, ver, exp ] = splitDirectories outcsv
231
234
example <- fromMaybe (error $ " Unknown example " <> exampleName)
232
235
<$> askOracle (GetExample exampleName)
233
236
buildSystem <- askOracle $ GetBuildSystem ()
234
237
setupRes <- setupProject
235
238
liftIO $ createDirectoryIfMissing True $ dropFileName outcsv
236
239
let exePath = build </> " binaries" </> ver </> executableName
237
- exeExtraArgs = [" +RTS" , " -I0.5 " , " -S " <> takeFileName outGc, " -RTS" ]
240
+ exeExtraArgs = [" +RTS" , " -l-a " , " -h " , " -ol " <> outEventLog, " -S " <> outGc, " -RTS" ]
238
241
ghcPath = build </> " binaries" </> ver </> " ghc.path"
239
242
experiment = Escaped $ dropExtension exp
240
243
need [exePath, ghcPath]
@@ -247,8 +250,8 @@ benchRules build benchResource MkBenchRules{..} = do
247
250
RemEnv " GHC_PACKAGE_PATH" ,
248
251
AddPath [takeDirectory ghcPath, " ." ] []
249
252
]
250
- BenchProject {.. }
251
- cmd_ Shell $ " mv *.benchmark-gcStats " <> dropFileName outcsv
253
+ BenchProject {.. }
254
+ liftIO $ renameFile " ghcide.hp " $ dropFileName outcsv </> dropExtension exp <.> " hp "
252
255
253
256
-- extend csv output with allocation data
254
257
csvContents <- liftIO $ lines <$> readFile outcsv
@@ -378,6 +381,11 @@ svgRules build = do
378
381
title = show (unescapeExperiment exp ) <> " - live bytes over time"
379
382
plotDiagram False diagram out
380
383
384
+ eventlogRules :: FilePattern -> Rules ()
385
+ eventlogRules build = do
386
+ build -/- " */*/*.eventlog.html" %> \ out -> do
387
+ need [dropExtension out]
388
+ cmd_ (" eventlog2html" :: String ) [dropExtension out]
381
389
382
390
--------------------------------------------------------------------------------
383
391
--------------------------------------------------------------------------------
0 commit comments