on master help sign in
Only print mem stats when getGCStatsEnabled
5d08cd1Hamish Mackenzie
jsaddle/src/Language/Javascript/JSaddle/Run.hs+6−4
@@ -64,7 +64,7 @@ import Language.Javascript.JSaddle.Types
64import Language.Javascript.JSaddle.Exception (JSException(..))
64import Language.Javascript.JSaddle.Exception (JSException(..))
65-- import Language.Javascript.JSaddle.Native.Internal (wrapJSVal)
65-- import Language.Javascript.JSaddle.Native.Internal (wrapJSVal)
66import Control.DeepSeq (deepseq)
66import Control.DeepSeq (deepseq)
67−import GHC.Stats (getGCStats, GCStats(..))
67+import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
68#endif
68#endif
69
69
70-- | Forces execution of pending asyncronous code
70-- | Forces execution of pending asyncronous code
@@ -167,9 +167,11 @@ runJavaScript sendBatch entryPoint = do
167 Just cb -> void . forkIO $ runReaderT (unJSM $ cb f' this' args) ctx
167 Just cb -> void . forkIO $ runReaderT (unJSM $ cb f' this' args) ctx
168 m -> putMVar recvMVar m
168 m -> putMVar recvMVar m
169 logInfo s = do
169 logInfo s = do
170+ stats <- getGCStatsEnabled
171+ when stats $ do
170− current <- currentBytesUsed <$> getGCStats
172+ current <- currentBytesUsed <$> getGCStats
171− cbCount <- M.size <$> readTVarIO callbacks
173+ cbCount <- M.size <$> readTVarIO callbacks
172− putStrLn . s $ show (current, cbCount)
174+ putStrLn . s $ show (current, cbCount)
173 _ <- forkIO . forever $ readBatch commandChan >>= \case
175 _ <- forkIO . forever $ readBatch commandChan >>= \case
174 (batch@(Batch cmds _), resultMVars) -> do
176 (batch@(Batch cmds _), resultMVars) -> do
175 logInfo (\x -> "Sync " <> x <> show (length cmds, last cmds))
177 logInfo (\x -> "Sync " <> x <> show (length cmds, last cmds))