perf 0.8.0 → 0.9.0
raw patch · 3 files changed
+30/−32 lines, 3 filesdep −deepseq
Dependencies removed: deepseq
Files
- ChangeLog.md +5/−0
- perf.cabal +16/−22
- src/Perf/Cycle.hs +9/−10
ChangeLog.md view
@@ -1,3 +1,8 @@+0.9.0+===+* Removed deepseq dependency++ 0.8.0 === * GHC 9.0.1 support
perf.cabal view
@@ -1,24 +1,23 @@-cabal-version: 2.4-name: perf-version: 0.8.0-synopsis: Low-level run time measurement.+cabal-version: 2.4+name: perf+version: 0.9.0+synopsis: Low-level run time measurement. description: A set of tools to accurately measure time performance of Haskell programs. perf aims to be lightweight by having minimal dependencies on standard libraries. See the Perf module for an example and full API documentation. -category: project-homepage: https://github.com/tonyday567/perf#readme-bug-reports: https://github.com/tonyday567/perf/issues-author: Tony Day, Marco Zocca-maintainer: tonyday567@gmail.com-copyright: Tony Day-license: BSD-3-Clause-license-file: LICENSE-build-type: Simple-tested-with: GHC ==8.8.4 || ==8.10.4 || ==9.0.1 || ==9.2.0.20210821-extra-source-files:- ChangeLog.md+category: project+homepage: https://github.com/tonyday567/perf#readme+bug-reports: https://github.com/tonyday567/perf/issues+author: Tony Day, Marco Zocca+maintainer: tonyday567@gmail.com+copyright: Tony Day+license: BSD-3-Clause+license-file: LICENSE+build-type: Simple+tested-with: GHC ==8.8.4 || ==8.10.4 || ==9.0.1 || ==9.2.0.20210821+extra-source-files: ChangeLog.md source-repository head type: git@@ -34,12 +33,11 @@ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fwrite-ide-info- -hiedir=.hie+ -hiedir=.hie -Wunused-packages build-depends: , base >=4.7 && <5 , containers ^>=0.6- , deepseq ^>=1.4 , foldl ^>=1.4 , mtl ^>=2.2.2 , rdtsc ^>=1.3@@ -49,7 +47,3 @@ default-language: Haskell2010 default-extensions:- ghc-options:- -Wall -Wcompat -Wincomplete-record-updates- -Wincomplete-uni-patterns -Wredundant-constraints -fwrite-ide-info- -hiedir=.hie
src/Perf/Cycle.hs view
@@ -28,7 +28,6 @@ ) where -import Control.DeepSeq (NFData (..), force) import qualified Control.Foldl as L (fold, genericLength, premap, sum) import Control.Monad (replicateM) import Data.Foldable (toList)@@ -95,10 +94,10 @@ pure $ average ts -- | tick where the arguments are lazy, so measurement may include evaluation of thunks that may constitute f and/or a-tick' :: (NFData b) => (a -> b) -> a -> IO (Cycle, b)+tick' :: (a -> b) -> a -> IO (Cycle, b) tick' f a = do !t <- rdtsc- !a' <- pure (force $ f a)+ !a' <- pure (f a) !t' <- rdtsc pure (t' - t, a') {-# INLINE tick' #-}@@ -109,25 +108,25 @@ -- >>> (cs, _) <- tick f a -- -- Note that feeding the same computation through tick twice may kick off sharing (aka memoization aka let floating). Given the importance of sharing to GHC optimisations this is the intended behaviour. If you want to turn this off then see -fno-full-laziness (and maybe -fno-cse).-tick :: (NFData b) => (a -> b) -> a -> IO (Cycle, b)+tick :: (a -> b) -> a -> IO (Cycle, b) tick !f !a = tick' f a {-# INLINE tick #-} -tickNoinline :: (NFData b) => (a -> b) -> a -> IO (Cycle, b)+tickNoinline :: (a -> b) -> a -> IO (Cycle, b) tickNoinline !f !a = tick' f a {-# NOINLINE tickNoinline #-} -- | measures and deeply evaluates an `IO a` -- -- >>> (cs, _) <- tickIO (pure (f a))-tickIO :: (NFData a) => IO a -> IO (Cycle, a)+tickIO :: IO a -> IO (Cycle, a) tickIO a = do t <- rdtsc- !a' <- force <$> a+ !a' <- a t' <- rdtsc pure (t' - t, a') -tickIONoinline :: (NFData a) => IO a -> IO (Cycle, a)+tickIONoinline :: IO a -> IO (Cycle, a) tickIONoinline = tickIO {-# NOINLINE tickIONoinline #-} @@ -150,7 +149,7 @@ -- > fPoly x = foldl' (+) 0 [1 .. x] -- > fLambda :: Int -> Int -- > fLambda = \x -> foldl' (+) 0 [1 .. x]-ticks :: NFData b => Int -> (a -> b) -> a -> IO ([Cycle], b)+ticks :: Int -> (a -> b) -> a -> IO ([Cycle], b) ticks n0 f a = go f a n0 Empty where go f' a' n ts@@ -165,7 +164,7 @@ -- returns an IO tuple; list of Cycles and the last evaluated f a -- -- >>> (cs, fa) <- ticksIO n (pure $ f a)-ticksIO :: (NFData a) => Int -> IO a -> IO ([Cycle], a)+ticksIO :: Int -> IO a -> IO ([Cycle], a) ticksIO n0 a = go a n0 Empty where go a' n ts