Plot-ho-matic 0.12.2.2 → 0.12.2.3
raw patch · 5 files changed
+41/−16 lines, 5 files
Files
- CHANGELOG.md +5/−0
- Plot-ho-matic.cabal +3/−2
- src/PlotHo/Plotter.hs +5/−7
- src/PlotHoCommon.hs +23/−0
- src/SetHo.hs +5/−7
CHANGELOG.md view
@@ -1,3 +1,8 @@+HEAD+---+* RTS stats compatability+* upgrade stack LTS+ 0.12.2.0 --- * add a diff button to setHo
Plot-ho-matic.cabal view
@@ -1,5 +1,5 @@ name: Plot-ho-matic-version: 0.12.2.2+version: 0.12.2.3 synopsis: Real-time line plotter for generic data license: BSD3 license-file: LICENSE@@ -26,7 +26,8 @@ default-language: Haskell2010 exposed-modules: PlotHo, SetHo - other-modules: PlotHo.Channel+ other-modules: PlotHoCommon+ PlotHo.Channel PlotHo.ChartRender PlotHo.HistoryChannel PlotHo.GraphWidget
src/PlotHo/Plotter.hs view
@@ -6,8 +6,6 @@ ( runPlotter ) where -import qualified GHC.Stats- import Control.Monad ( unless, void ) import Control.Monad.IO.Class ( MonadIO(..) ) import qualified Control.Concurrent as CC@@ -22,6 +20,7 @@ import System.Glib.Signals ( on ) import Prelude +import PlotHoCommon ( getLiveBytes, getRTSStatsEnabled ) import PlotHo.GraphWidget ( newGraph ) import PlotHo.PlotTypes ( Channel(..), Channel'(..), PlotterOptions(..) ) @@ -29,7 +28,7 @@ runPlotter :: Maybe PlotterOptions -> [Channel] -> IO () runPlotter mplotterOptions channels = do let plotterOptions = fromMaybe def mplotterOptions- statsEnabled <- GHC.Stats.getGCStatsEnabled+ rtsStatsEnabled <- getRTSStatsEnabled unless CC.rtsSupportsBoundThreads $ do putStr $ unlines@@ -52,11 +51,10 @@ statsLabel <- Gtk.labelNew (Nothing :: Maybe String) let statsWorker = do CC.threadDelay 500000- msg <- if statsEnabled+ msg <- if rtsStatsEnabled then do- stats <- GHC.Stats.getGCStats- return $ printf "The current memory usage is %.2f MB"- ((realToFrac (GHC.Stats.currentBytesUsed stats) :: Double) /(1024*1024))+ liveBytes <- getLiveBytes+ return $ printf "The current memory usage is %.2f MB" (liveBytes /(1024*1024)) else return "(enable GHC statistics with +RTS -T)" Gtk.postGUISync $ Gtk.labelSetText statsLabel ("Welcome to Plot-ho-matic!\n" ++ msg) statsWorker
+ src/PlotHoCommon.hs view
@@ -0,0 +1,23 @@+{-# OPTIONS_GHC -Wall #-}+{-# Language CPP #-}++module PlotHoCommon+ ( getRTSStatsEnabled+ , getLiveBytes+ ) where++import qualified GHC.Stats++getRTSStatsEnabled :: IO Bool+#if __GLASGOW_HASKELL__ >= 802+getRTSStatsEnabled = GHC.Stats.getRTSStatsEnabled+#else+getRTSStatsEnabled = GHC.Stats.getGCStatsEnabled+#endif++getLiveBytes :: IO Double+#if __GLASGOW_HASKELL__ >= 802+getLiveBytes = realToFrac . GHC.Stats.gcdetails_live_bytes . GHC.Stats.gc <$> GHC.Stats.getRTSStats+#else+getLiveBytes = realToFrac . GHC.Stats.currentBytesUsed <$> GHC.Stats.getGCStats+#endif
src/SetHo.hs view
@@ -9,8 +9,6 @@ , runSetter ) where -import qualified GHC.Stats- import Accessors.Dynamic ( DTree ) import qualified Control.Concurrent as CC import Control.Monad.IO.Class ( liftIO )@@ -22,6 +20,7 @@ import Text.Printf ( printf ) import System.Glib.Signals ( on ) +import PlotHoCommon ( getLiveBytes, getRTSStatsEnabled ) import SetHo.LookupTree ( newLookupTreeview ) data SetHoConfig@@ -45,7 +44,7 @@ let config = case mconfig of Just r -> r Nothing -> defaultSetHoConfig- statsEnabled <- GHC.Stats.getGCStatsEnabled+ rtsStatsEnabled <- getRTSStatsEnabled counterRef <- newIORef 0 upstreamCounterRef <- newIORef Nothing@@ -61,11 +60,10 @@ statsLabel <- Gtk.labelNew (Nothing :: Maybe String) let makeStatsMessage = do- statsMsg <- if statsEnabled+ statsMsg <- if rtsStatsEnabled then do- stats <- GHC.Stats.getGCStats- return $ printf "The current memory usage is %.2f MB"- ((realToFrac (GHC.Stats.currentBytesUsed stats) :: Double) /(1024*1024))+ liveBytes <- getLiveBytes+ return $ printf "The current memory usage is %.2f MB" (liveBytes /(1024*1024)) else return "(enable GHC statistics with +RTS -T)" counter <- readIORef counterRef mupstreamCounter <- readIORef upstreamCounterRef