weigh 0.0.16 → 0.0.18
raw patch · 4 files changed
Files
- CHANGELOG +6/−0
- README.md +1/−1
- src/Weigh.hs +12/−3
- weigh.cabal +5/−3
CHANGELOG view
@@ -1,3 +1,9 @@+0.0.18:+ * Fix compatibility with `mtl`, whenever different version from the one that is wired with ghc is used.++0.0.17:+ * Changes to make compatible for GHC 9.6+ 0.0.16: * Add MaxOS parameter to indicate memory in use by RTS * Add haddock docmentation to the 'Column' type
README.md view
@@ -1,4 +1,4 @@-# weigh [](https://travis-ci.org/fpco/weigh)+# weigh [](https://github.com/fpco/weigh/actions/workflows/tests.yml) Measures the memory usage of a Haskell value or function
src/Weigh.hs view
@@ -3,7 +3,6 @@ {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ViewPatterns #-}@@ -75,7 +74,9 @@ import Control.Applicative import Control.Arrow import Control.DeepSeq-import Control.Monad.State+import Control.Monad (unless)+import Control.Monad.State (State, execState, get, gets, modify)+import Criterion.Measurement import qualified Data.Foldable as Foldable import qualified Data.List as List import Data.List.Split@@ -107,6 +108,7 @@ | MaxOS -- ^ Maximum memory in use by the RTS. Valid only for -- GHC >= 8.2.2. For unsupported GHC, this is reported -- as 0.+ | WallTime -- ^ Rough execution time. For general indication, not a benchmark tool. deriving (Show, Eq, Enum) -- | Weigh configuration.@@ -132,6 +134,7 @@ ,weightLiveBytes :: !Word64 ,weightMaxBytes :: !Word64 ,weightMaxOSBytes :: !Word64+ ,weightWallTime :: !Double } deriving (Read,Show) @@ -251,7 +254,7 @@ -- Implemented in terms of 'validateAction'. io :: (NFData a) => String -- ^ Name of the case.- -> (b -> IO a) -- ^ Aciton that does some IO to measure.+ -> (b -> IO a) -- ^ Action that does some IO to measure. -> b -- ^ Argument to that function. -> Weigh () io name !f !x = validateAction name f x (const Nothing)@@ -339,10 +342,13 @@ Just act -> do case act of Action !run arg _ _ -> do+ initializeTime+ start <- getTime (bytes, gcs, liveBytes, maxByte, maxOSBytes) <- case run of Right f -> weighFunc f arg Left m -> weighAction m arg+ end <- getTime writeFile fp (show@@ -353,6 +359,7 @@ , weightLiveBytes = liveBytes , weightMaxBytes = maxByte , weightMaxOSBytes = maxOSBytes+ , weightWallTime = end - start })) return Nothing _ -> fmap Just (Traversable.traverse (Traversable.traverse fork) cases)@@ -568,6 +575,7 @@ , (Check, (True, "Check")) , (Max, (False, "Max")) , (MaxOS, (False, "MaxOS"))+ , (WallTime, (False, "Wall Time")) ] toRow (w, err) = [ (Case, (True, takeLastAfterBk $ weightLabel w))@@ -576,6 +584,7 @@ , (Live, (False, commas (weightLiveBytes w))) , (Max, (False, commas (weightMaxBytes w))) , (MaxOS, (False, commas (weightMaxOSBytes w)))+ , (WallTime, (False, printf "%.3fs" (weightWallTime w))) , ( Check , ( True , case err of
weigh.cabal view
@@ -1,5 +1,5 @@ name: weigh-version: 0.0.16+version: 0.0.18 synopsis: Measure allocations of a Haskell functions/values description: Please see README.md homepage: https://github.com/fpco/weigh#readme@@ -25,14 +25,16 @@ , mtl , split , temporary- , ghc >= 8.2.1+ , criterion-measurement default-language: Haskell2010+ if impl(ghc < 8.2.1)+ buildable: False test-suite weigh-test default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: src/test- ghc-options: -O2+ ghc-options: -O2 -Wall main-is: Main.hs build-depends: base , weigh