packages feed

gauge 0.2.4 → 0.2.5

raw patch · 8 files changed

+90/−22 lines, 8 filesdep ~basedep ~basementPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, basement

API changes (from Hackage documentation)

- Gauge.Benchmark: Benchmarkable :: Int64 -> IO a -> Int64 -> a -> IO () -> a -> Int64 -> IO () -> Bool -> Benchmarkable
+ Gauge.Benchmark: Benchmarkable :: (Int64 -> IO a) -> (Int64 -> a -> IO ()) -> (a -> Int64 -> IO ()) -> Bool -> Benchmarkable
- Gauge.Main.Options: makeSelector :: MatchType -> [String] -> (String -> Bool)
+ Gauge.Main.Options: makeSelector :: MatchType -> [String] -> String -> Bool

Files

Gauge/Benchmark.hs view
@@ -511,7 +511,7 @@ iterateBenchmarkable :: Benchmarkable                  -> Int64                  -> (a -> a -> a)-                 -> (IO () -> IO a)+                 -> (Int64 -> IO () -> IO a)                  -> IO a iterateBenchmarkable Benchmarkable{..} i comb f     | perRun = work >>= go (i - 1)@@ -531,12 +531,12 @@         clean `seq` run `seq` evaluate $ rnf env0          performGC-        f run `finally` clean <* performGC+        f count run `finally` clean <* performGC     {-# INLINE work #-} {-# INLINE iterateBenchmarkable #-}  iterateBenchmarkable_ :: Benchmarkable -> Int64 -> IO ()-iterateBenchmarkable_ bm i = iterateBenchmarkable bm i (\() () -> ()) id+iterateBenchmarkable_ bm i = iterateBenchmarkable bm i (\() () -> ()) (const id) {-# INLINE iterateBenchmarkable_ #-}  series :: Double -> Maybe (Int64, Double)@@ -573,7 +573,7 @@             let !v = V.reverse (V.fromList acc)             return (v, endTime - start, iTotal)           else do-               m <- measure (iterateBenchmarkable bm iters) iters+               m <- measure (iterateBenchmarkable bm iters)                if measTime m >= milliSecondsToDouble minDuration                then loop niters (iTotal + iters) (m:acc)                else loop niters (iTotal + iters) (acc)
Gauge/Main/Options.hs view
@@ -24,8 +24,6 @@     , Mode (..)     ) where --- Temporary: to support pre-AMP GHC 7.8.4:-import Data.Monoid import Gauge.Measurement        (validateAccessors, defaultMinSamplesNormal,         defaultMinSamplesQuick, defaultTimeLimitNormal,@@ -263,7 +261,7 @@                     "exact"    -> Exact                     "pattern"  -> Pattern                     "ipattern" -> IPattern-                    _          -> optionError ("unknown match type: " <> s)+                    _          -> optionError ("unknown match type: " ++ s)          in v { match = m }     setMode m v = v { mode = m }     setDisplayMode m v = v { displayMode = m }@@ -307,12 +305,12 @@ describe = usageInfo header opts  header :: String-header = "Microbenchmark suite - " <> versionInfo+header = "Microbenchmark suite - " ++ versionInfo  -- | A string describing the version of this benchmark (really, the -- version of gauge that was used to build it). versionInfo :: String-versionInfo = "built with gauge " <> showVersion version+versionInfo = "built with gauge " ++ showVersion version  regressParams :: String -> ([String], String) regressParams m
Gauge/Measurement.hs view
@@ -362,10 +362,9 @@ -- | Invokes the supplied benchmark runner function with a combiner and a -- measurer that returns the measurement of a single iteration of an IO action. measure :: ((Measured -> Measured -> Measured)-            -> (IO () -> IO Measured) -> IO Measured)-        -> Int64         -- ^ Number of iterations.+        -> (Int64 -> IO () -> IO Measured) -> IO Measured)         -> IO Measured-measure run iters = run addResults $ \act -> do+measure run = run addResults $ \ !iters act -> do #ifdef GAUGE_MEASURE_TIME_NEW     ((Time.TimeRecord time cpuTime cycles, startRUsage, endRUsage), gcStats) <- GC.withMetrics $ RUsage.with RUsage.Self $ measureTime act #else
Gauge/Source/GC.hs view
@@ -43,7 +43,9 @@  supportedVar :: IORef Bool supportedVar = unsafePerformIO $ do-#if MIN_VERSION_base(4,10,0)+#if __GHCJS__+    let b = False+#elif MIN_VERSION_base(4,10,0)     b <- GHC.getRTSStatsEnabled #else     b <- (const True <$> GHC.getGCStats) `Exn.catch` \(_ :: Exn.SomeException) -> pure False
Gauge/Source/Time.hsc view
@@ -4,6 +4,7 @@ -- -- Various system time gathering methods --+{-# LANGUAGE CPP               #-} {-# LANGUAGE BangPatterns               #-} {-# LANGUAGE ForeignFunctionInterface   #-} {-# LANGUAGE KindSignatures             #-}@@ -32,6 +33,10 @@ import Foreign.Marshal.Alloc (alloca, allocaBytes) import Prelude -- Silence redundant import warnings +#ifdef __GHCJS__+import Foreign.C+#endif+ data MeasurementType = Differential | Absolute  newtype ClockTime (ty :: MeasurementType) = ClockTime Word64@@ -71,6 +76,58 @@     getRecordPtr ptr2     (,,) <$> pure a <*> peek ptr <*> peek ptr2 +#ifdef __GHCJS__+data CTimespec = MkCTimespec CTime CLong++instance Storable CTimespec where+    sizeOf _ = 8+    alignment _ = 4+    peek p = do+      s  <- peekByteOff p 0+      ns <- peekByteOff p 4+      return (MkCTimespec s ns)+    poke p (MkCTimespec s ns) = do+      pokeByteOff p 0 s+      pokeByteOff p 4 ns++foreign import ccall unsafe "time.h clock_gettime"+    clock_gettime :: CInt -> Ptr CTimespec -> IO CInt++-- | Get the current POSIX time from the system clock.+getRecordPtr :: Ptr (TimeRecord 'Absolute) -> IO ()+getRecordPtr ptr = do+    MkCTimespec (CTime sec) (CLong nsec) <-+        alloca (\ptspec -> do+            throwErrnoIfMinus1_ "clock_gettime" $+                clock_gettime 0 ptspec+            peek ptspec+        )+    poke ptr (TimeRecord +        (ClockTime ((fromIntegral sec) * 1000000000 + fromIntegral nsec))+        (CpuTime 0)+        (Cycles 0))++initialize :: IO ()+initialize = return ()++getCycles :: IO (Cycles 'Absolute)+getCycles = error "GHCJS does not support measuring cycles"++getTime :: IO Double+getTime = do+    MkCTimespec (CTime sec) (CLong nsec) <-+        alloca (\ptspec -> do+            throwErrnoIfMinus1_ "clock_gettime" $+                clock_gettime 0 ptspec+            peek ptspec+        )+    return $ fromIntegral sec + (fromIntegral nsec / 1000000000)++getCPUTime :: IO Double+getCPUTime = error "GHCJS does not support measuring CPUTime"++#else+ -- | Set up time measurement. foreign import ccall unsafe "gauge_inittime" initialize :: IO () @@ -89,3 +146,4 @@  -- | Record clock, cpu and cycles in one structure foreign import ccall unsafe "gauge_record" getRecordPtr :: Ptr (TimeRecord 'Absolute) -> IO ()+#endif
changelog.md view
@@ -1,3 +1,9 @@+# 0.2.5++* Add GHCJS support (statistical analysis is not supported)+* Fix issue with perRunEnv+* Drop support for GHC 7.8+ # 0.2.4  * `Enhancement`: Add `nfAppIO` and `whnfAppIO` functions, which take a function
gauge.cabal view
@@ -1,5 +1,5 @@ name:           gauge-version:        0.2.4+version:        0.2.5 synopsis:       small framework for performance measurement and analysis license:        BSD3 license-file:   LICENSE@@ -16,11 +16,12 @@   changelog.md   cbits/*.h tested-with:-  GHC==7.8.4,   GHC==7.10.3,   GHC==8.0.2,   GHC==8.2.2,-  GHC==8.4.3+  GHC==8.4.3,+  GHC==8.6.5,+  GHC==8.8.1  description:   This library provides a powerful but simple way to measure software@@ -54,7 +55,7 @@     Gauge.Source.Time     System.Random.MWC -  if flag(analysis)+  if flag(analysis) && !impl(ghcjs)       exposed-modules:         Gauge.Analysis       other-modules:@@ -101,6 +102,9 @@   other-modules:     Paths_gauge +  if impl(ghc < 7.10)+    buildable: False+   build-depends:     base >= 4.7 && < 5,     basement >= 0.0.4,@@ -111,7 +115,7 @@    default-language: Haskell2010   ghc-options: -O2 -Wall -funbox-strict-fields-  if flag(analysis)+  if flag(analysis) && !impl(ghcjs)       cpp-options: -DHAVE_ANALYSIS  test-suite sanity@@ -122,9 +126,10 @@   ghc-options:          -O2 -Wall -rtsopts    build-depends:-    base,+    base > 0 && < 1000,     bytestring,     gauge,+    basement,     foundation  test-suite cleanup@@ -137,7 +142,7 @@     -Wall -threaded     -O0 -rtsopts    build-depends:-    base,+    base > 0 && < 1000,     bytestring,     gauge,     deepseq,@@ -150,7 +155,7 @@   default-language:     Haskell2010   main-is:              Main.hs   build-depends:-    base,+    base > 0 && < 1000,     gauge  source-repository head
tests/Sanity.hs view
@@ -2,7 +2,6 @@ {-# LANGUAGE OverloadedStrings #-}  import           System.Timeout (timeout)-import           Data.Monoid import           Data.Word import           GHC.Exts (IsList(..)) @@ -10,6 +9,7 @@ import           Gauge.Main.Options import           Gauge.Benchmark (bench, bgroup, env, whnf) +import           Basement.Compat.Base ((<>)) import           Foundation.Check import           Foundation.Check.Main