packages feed

weigh 0.0.12 → 0.0.13

raw patch · 3 files changed

+38/−12 lines, 3 files

Files

CHANGELOG view
@@ -1,3 +1,6 @@+0.0.13:+	* Forward arguments to the child process+ 0.0.12: 	* Fix bug in non-unique groupings 
src/Weigh.hs view
@@ -64,7 +64,9 @@   -- * Internals   ,weighDispatch   ,weighFunc+  ,weighFuncResult   ,weighAction+  ,weighActionResult   ,Grouped(..)   )   where@@ -350,10 +352,11 @@        hClose h        setEnv "WEIGH_CASE" $ show $ [actionName act,fp]        me <- getExecutablePath+       args <- getArgs        (exit, _, err) <-          readProcessWithExitCode            me-           ["+RTS", "-T", "-RTS"]+           (args ++ ["+RTS", "-T", "-RTS"])            ""        case exit of          ExitFailure {} ->@@ -371,13 +374,23 @@                     , "processes via a temporary file."                     ])) --- | Weigh a pure function. This function is heavily documented inside.+-- | Weigh a pure function. This function is built on top of `weighFuncResult`,+--   which is heavily documented inside weighFunc   :: (NFData a)   => (b -> a)         -- ^ A function whose memory use we want to measure.   -> b                -- ^ Argument to the function. Doesn't have to be forced.   -> IO (Int64,Int64,Int64,Int64) -- ^ Bytes allocated and garbage collections.-weighFunc run !arg = do+weighFunc run !arg = snd <$> weighFuncResult run arg++-- | Weigh a pure function and return the result. This function is heavily+--   documented inside.+weighFuncResult+  :: (NFData a)+  => (b -> a)         -- ^ A function whose memory use we want to measure.+  -> b                -- ^ Argument to the function. Doesn't have to be forced.+  -> IO (a, (Int64,Int64,Int64,Int64)) -- ^ Result, Bytes allocated, GCs.+weighFuncResult run !arg = do   ghcStatsSizeInBytes <- GHCStats.getGhcStatsSizeInBytes   performGC      -- The above forces getStats data to be generated NOW.@@ -385,7 +398,7 @@      -- We need the above to subtract "program startup" overhead. This      -- operation itself adds n bytes for the size of GCStats, but we      -- subtract again that later.-  let !_ = force (run arg)+  let !result = force (run arg)   performGC      -- The above forces getStats data to be generated NOW.   !actionStats <- GHCStats.getStats@@ -410,19 +423,29 @@           0           (GHCStats.maxBytesInUse actionStats -            GHCStats.maxBytesInUse bootupStats)-  return+  return (result,     ( fromIntegral actualBytes     , fromIntegral actionGCs     , fromIntegral liveBytes-    , fromIntegral maxBytes)+    , fromIntegral maxBytes)) --- | Weigh an IO action. This function is heavily documented inside.+-- | Weigh an IO action. This function is based on `weighActionResult`, which is+--   heavily documented inside. weighAction   :: (NFData a)   => (b -> IO a)      -- ^ A function whose memory use we want to measure.   -> b                -- ^ Argument to the function. Doesn't have to be forced.   -> IO (Int64,Int64,Int64,Int64) -- ^ Bytes allocated and garbage collections.-weighAction run !arg = do+weighAction run !arg = snd <$> weighActionResult run arg++-- | Weigh an IO action, and return the result. This function is heavily+--   documented inside.+weighActionResult+  :: (NFData a)+  => (b -> IO a)      -- ^ A function whose memory use we want to measure.+  -> b                -- ^ Argument to the function. Doesn't have to be forced.+  -> IO (a, (Int64,Int64,Int64,Int64)) -- ^ Result, Bytes allocated and GCs.+weighActionResult run !arg = do   ghcStatsSizeInBytes <- GHCStats.getGhcStatsSizeInBytes   performGC      -- The above forces getStats data to be generated NOW.@@ -430,7 +453,7 @@      -- We need the above to subtract "program startup" overhead. This      -- operation itself adds n bytes for the size of GCStats, but we      -- subtract again that later.-  !_ <- fmap force (run arg)+  !result <- fmap force (run arg)   performGC      -- The above forces getStats data to be generated NOW.   !actionStats <- GHCStats.getStats@@ -455,11 +478,11 @@           0           (GHCStats.maxBytesInUse actionStats -            GHCStats.maxBytesInUse bootupStats)-  return+  return (result,     ( fromIntegral actualBytes     , fromIntegral actionGCs     , fromIntegral liveBytes-    , fromIntegral maxBytes)+    , fromIntegral maxBytes))  -------------------------------------------------------------------------------- -- Formatting functions
weigh.cabal view
@@ -1,5 +1,5 @@ name:                weigh-version:             0.0.12+version:             0.0.13 synopsis:            Measure allocations of a Haskell functions/values description:         Please see README.md homepage:            https://github.com/fpco/weigh#readme