packages feed

criterion-measurement 0.1.4.0 → 0.2.0.0

raw patch · 4 files changed

+28/−11 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Criterion.Measurement.Types: [measPeakMbAllocated] :: Measured -> !Int64
- Criterion.Measurement.Types: Measured :: !Double -> !Double -> !Int64 -> !Int64 -> !Int64 -> !Int64 -> !Int64 -> !Double -> !Double -> !Double -> !Double -> Measured
+ Criterion.Measurement.Types: Measured :: !Double -> !Double -> !Int64 -> !Int64 -> !Int64 -> !Int64 -> !Int64 -> !Int64 -> !Double -> !Double -> !Double -> !Double -> Measured

Files

changelog.md view
@@ -1,3 +1,9 @@+0.2.0.0++* Add a `measPeakMbAllocated` field to `Measured` for reporting maximum+  megabytes allocated. Naturally, this affects the behavior of `Measured`'s+  `{To,From}JSON` and `Binary` instances.+ 0.1.4.0  * Fix a bug that occurred with GHC 9.2.4 or later that would cause incorrect
criterion-measurement.cabal view
@@ -1,5 +1,5 @@ name:                criterion-measurement-version:             0.1.4.0+version:             0.2.0.0 synopsis:            Criterion measurement functionality and associated types description:         Measurement-related functionality extracted from Criterion, with minimal dependencies. The rationale for this is to enable alternative analysis front-ends. homepage:            https://github.com/haskell/criterion
src/Criterion/Measurement.hs view
@@ -182,7 +182,7 @@ measure :: Benchmarkable        -- ^ Operation to benchmark.         -> Int64                -- ^ Number of iterations.         -> IO (Measured, Double)-measure bm iters = runBenchmarkable bm iters addResults $ \ !n act -> do+measure bm iters = runBenchmarkable bm iters combineResults $ \ !n act -> do   -- Ensure the stats from getGCStatistics are up-to-date   -- by garbage collecting. performMinorGC does /not/ update all stats, but   -- it does update the ones we need (see applyGCStatistics for details.@@ -216,11 +216,15 @@   where     -- When combining runs, the Measured value is accumulated over many runs,     -- but the Double value is the most recent absolute measurement of time.-    addResults :: (Measured, Double) -> (Measured, Double) -> (Measured, Double)-    addResults (!m1, _) (!m2, !d2) = (m3, d2)+    combineResults :: (Measured, Double) -> (Measured, Double) -> (Measured, Double)+    combineResults (!m1, _) (!m2, !d2) = (m3, d2)       where-        add f = f m1 + f m2+        combine :: (a -> a -> a) -> (Measured -> a) -> a+        combine g sel = sel m1 `g` sel m2 +        add :: Num a => (Measured -> a) -> a+        add = combine (+)+         m3 = Measured             { measTime               = add measTime             , measCpuTime            = add measCpuTime@@ -228,6 +232,7 @@             , measIters              = add measIters              , measAllocated          = add measAllocated+            , measPeakMbAllocated    = combine max measPeakMbAllocated             , measNumGcs             = add measNumGcs             , measBytesCopied        = add measBytesCopied             , measMutatorWallSeconds = add measMutatorWallSeconds@@ -334,6 +339,7 @@     , measIters              = 0      , measAllocated          = minBound+    , measPeakMbAllocated    = minBound     , measNumGcs             = minBound     , measBytesCopied        = minBound     , measMutatorWallSeconds = bad@@ -360,6 +366,7 @@     -- The others (num GCs and GC cpu/wall seconds) must be diffed against     -- endPreGC so that the extra performGC does not taint them.     measAllocated          = diff endPostGC gcStatsBytesAllocated+  , measPeakMbAllocated    = gcStatsPeakMegabytesAllocated endPostGC   , measNumGcs             = diff endPreGC  gcStatsNumGcs   , measBytesCopied        = diff endPostGC gcStatsBytesCopied   , measMutatorWallSeconds = diff endPostGC gcStatsMutatorWallSeconds
src/Criterion/Measurement/Types.hs view
@@ -125,6 +125,8 @@      , measAllocated          :: !Int64       -- ^ __(GC)__ Number of bytes allocated.  Access using 'fromInt'.+    , measPeakMbAllocated    :: !Int64+      -- ^ __(GC)__ Max number of megabytes allocated.  Access using 'fromInt'.     , measNumGcs             :: !Int64       -- ^ __(GC)__ Number of garbage collections performed.  Access       -- using 'fromInt'.@@ -148,11 +150,11 @@  instance FromJSON Measured where     parseJSON v = do-      (a,b,c,d,e,f,g,h,i,j,k) <- parseJSON v+      (a,b,c,d,e,f,g,h,i,j,k,l) <- parseJSON v       -- The first four fields are not subject to the encoding policy:       return $ Measured a b c d-                       (int e) (int f) (int g)-                       (db h) (db i) (db j) (db k)+                       (int e) (int f) (int g) (int h)+                       (db i) (db j) (db k) (db l)       where int = toInt; db = toDouble  -- Here we treat the numeric fields as `Maybe Int64` and `Maybe Double`@@ -161,7 +163,7 @@ instance ToJSON Measured where     toJSON Measured{..} = toJSON       (measTime, measCpuTime, measCycles, measIters,-       i measAllocated, i measNumGcs, i measBytesCopied,+       i measAllocated, i measPeakMbAllocated, i measNumGcs, i measBytesCopied,        d measMutatorWallSeconds, d measMutatorCpuSeconds,        d measGcWallSeconds, d measGcCpuSeconds)       where i = fromInt; d = fromDouble@@ -186,6 +188,8 @@                             "loop iterations"))   , ("allocated",          (fmap fromIntegral . fromInt . measAllocated,                             "(+RTS -T) bytes allocated"))+  , ("peakMbAllocated",    (fmap fromIntegral . fromInt . measPeakMbAllocated,+                            "(+RTS -T) peak megabytes allocated"))   , ("numGcs",             (fmap fromIntegral . fromInt . measNumGcs,                             "(+RTS -T) number of garbage collections"))   , ("bytesCopied",        (fmap fromIntegral . fromInt . measBytesCopied,@@ -260,10 +264,10 @@ instance Binary Measured where     put Measured{..} = do       put measTime; put measCpuTime; put measCycles; put measIters-      put measAllocated; put measNumGcs; put measBytesCopied+      put measAllocated; put measPeakMbAllocated; put measNumGcs; put measBytesCopied       put measMutatorWallSeconds; put measMutatorCpuSeconds       put measGcWallSeconds; put measGcCpuSeconds-    get = Measured <$> get <*> get <*> get <*> get+    get = Measured <$> get <*> get <*> get <*> get <*> get                    <*> get <*> get <*> get <*> get <*> get <*> get <*> get  -- | Apply an argument to a function, and evaluate the result to