weigh 0.0.16 → 0.0.17
raw patch · 4 files changed
+20/−4 lines, 4 filesdep +criterion-measurementdep ~mtlnew-uploader
Dependencies added: criterion-measurement
Dependency ranges changed: mtl
Files
- CHANGELOG +3/−0
- README.md +1/−1
- src/Weigh.hs +13/−1
- weigh.cabal +3/−2
CHANGELOG view
@@ -1,3 +1,6 @@+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
@@ -75,7 +75,11 @@ import Control.Applicative import Control.Arrow import Control.DeepSeq+#if MIN_VERSION_base(4,18,0)+import Control.Monad (unless)+#endif import Control.Monad.State+import Criterion.Measurement import qualified Data.Foldable as Foldable import qualified Data.List as List import Data.List.Split@@ -107,6 +111,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 +137,7 @@ ,weightLiveBytes :: !Word64 ,weightMaxBytes :: !Word64 ,weightMaxOSBytes :: !Word64+ ,weightWallTime :: !Double } deriving (Read,Show) @@ -251,7 +257,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 +345,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 +362,7 @@ , weightLiveBytes = liveBytes , weightMaxBytes = maxByte , weightMaxOSBytes = maxOSBytes+ , weightWallTime = end - start })) return Nothing _ -> fmap Just (Traversable.traverse (Traversable.traverse fork) cases)@@ -568,6 +578,7 @@ , (Check, (True, "Check")) , (Max, (False, "Max")) , (MaxOS, (False, "MaxOS"))+ , (WallTime, (False, "Wall Time")) ] toRow (w, err) = [ (Case, (True, takeLastAfterBk $ weightLabel w))@@ -576,6 +587,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.17 synopsis: Measure allocations of a Haskell functions/values description: Please see README.md homepage: https://github.com/fpco/weigh#readme@@ -26,13 +26,14 @@ , split , temporary , ghc >= 8.2.1+ , criterion-measurement default-language: Haskell2010 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