on master help sign in
Only print mem stats when getGCStatsEnabled
commit5d08cd1d4bbe92af0213038b4a97779baf3c2dd9 authorHamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> dateMon 20 Feb 2017, 10:42 (10 years ago) parent460cf87
1 file changed+6−4
jsaddle/src/Language/Javascript/JSaddle/Run.hs+6−4
jsaddle/src/Language/Javascript/JSaddle/Run.hs+6−4
@@ -64,7 +64,7 @@ import Language.Javascript.JSaddle.Types
6464import Language.Javascript.JSaddle.Exception (JSException(..))
6565-- import Language.Javascript.JSaddle.Native.Internal (wrapJSVal)
6666import Control.DeepSeq (deepseq)
67−import GHC.Stats (getGCStats, GCStats(..))
67+import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
6868#endif
6969
7070-- | Forces execution of pending asyncronous code
@@ -167,9 +167,11 @@ runJavaScript sendBatch entryPoint = do
167167 Just cb -> void . forkIO $ runReaderT (unJSM $ cb f' this' args) ctx
168168 m -> putMVar recvMVar m
169169 logInfo s = do
170− current <- currentBytesUsed <$> getGCStats
171− cbCount <- M.size <$> readTVarIO callbacks
172− putStrLn . s $ show (current, cbCount)
170+ stats <- getGCStatsEnabled
171+ when stats $ do
172+ current <- currentBytesUsed <$> getGCStats
173+ cbCount <- M.size <$> readTVarIO callbacks
174+ putStrLn . s $ show (current, cbCount)
173175 _ <- forkIO . forever $ readBatch commandChan >>= \case
174176 (batch@(Batch cmds _), resultMVars) -> do
175177 logInfo (\x -> "Sync " <> x <> show (length cmds, last cmds))