on master help sign in
ob profile: Use finally to write profiling data
78d05a2Matthew Bauer
lib/command/src/Obelisk/Command/Run.hs+2−11
@@ -104,20 +104,11 @@ run profiled = withProjectRoot "." $ \root -> do
104 let exeSource =
104 let exeSource =
105 unlines $
105 unlines $
106 [ "module Main where"
106 [ "module Main where"
107− , "import Control.Concurrent"
107+ , "import Control.Exception"
108− , "import Control.Monad.Fix"
109 , "import Reflex.Profiled" ]
108 , "import Reflex.Profiled" ]
110 <> obRunImports <>
109 <> obRunImports <>
111 [ "main :: IO ()"
110 [ "main :: IO ()"
112− , "main = do"
113− , " forkIO $ fix $ \\rec -> do"
114− -- TODO: make this filename customizable
115− , " writeProfilingData \"" <> profileBaseName <> ".rprof\""
111+ , "main = " <> obRunExpr <> " `finally` writeProfilingData \"" <> profileBaseName <> ".rprof\"" ]
116− -- write every .1 seconds.
117− -- TODO: perhaps it should only write once at the end of ecah run
118− , " threadDelay 10000"
119− , " rec"
120− , " " <> obRunExpr]
121 -- Sane flags to enable by default, enable time profiling +
112 -- Sane flags to enable by default, enable time profiling +
122 -- closure heap profiling.
113 -- closure heap profiling.
123 rtsFlags = [ "+RTS", "-p", "-po" <> profileBaseName, "-hc", "-RTS" ]
114 rtsFlags = [ "+RTS", "-p", "-po" <> profileBaseName, "-hc", "-RTS" ]