on master help sign in
ob profile: Use finally to write profiling data

This avoids a call every .1 seconds.

commit78d05a2d6d4e832e8f3c47e8cedb4e5551605673 authorMatthew Bauer <mjbauer95@gmail.com> dateTue 11 Feb 2020, 12:38 (7 years ago) parentab48708
1 file changed+2−11
lib/command/src/Obelisk/Command/Run.hs+2−11
lib/command/src/Obelisk/Command/Run.hs+2−11
@@ -104,20 +104,11 @@ run profiled = withProjectRoot "." $ \root -> do
104104 let exeSource =
105105 unlines $
106106 [ "module Main where"
107− , "import Control.Concurrent"
108− , "import Control.Monad.Fix"
107+ , "import Control.Exception"
109108 , "import Reflex.Profiled" ]
110109 <> obRunImports <>
111110 [ "main :: IO ()"
112− , "main = do"
113− , " forkIO $ fix $ \\rec -> do"
114− -- TODO: make this filename customizable
115− , " 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]
111+ , "main = " <> obRunExpr <> " `finally` writeProfilingData \"" <> profileBaseName <> ".rprof\"" ]
121112 -- Sane flags to enable by default, enable time profiling +
122113 -- closure heap profiling.
123114 rtsFlags = [ "+RTS", "-p", "-po" <> profileBaseName, "-hc", "-RTS" ]