mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-12 15:28:29 +01:00
Fix criterion test suite bos/criterion#58
This commit is contained in:
parent
6e276c3bd3
commit
095358c2b7
@ -1,171 +0,0 @@
|
||||
diff -ru orig/Criterion/Analysis/Types.hs new/Criterion/Analysis/Types.hs
|
||||
--- orig/Criterion/Analysis/Types.hs 2014-04-10 08:02:35.383848688 +0300
|
||||
+++ new/Criterion/Analysis/Types.hs 2014-04-10 08:02:34.000000000 +0300
|
||||
@@ -19,10 +19,12 @@
|
||||
, SampleAnalysis(..)
|
||||
) where
|
||||
|
||||
+import Control.Applicative ((<$>), (<*>))
|
||||
import Control.DeepSeq (NFData(rnf))
|
||||
-import Data.Binary (Binary)
|
||||
+import Data.Binary (Binary, put, get)
|
||||
import Data.Data (Data, Typeable)
|
||||
import Data.Int (Int64)
|
||||
+import Data.Word (Word8)
|
||||
import Data.Monoid (Monoid(..))
|
||||
import GHC.Generics (Generic)
|
||||
import qualified Statistics.Resampling.Bootstrap as B
|
||||
@@ -42,7 +44,14 @@
|
||||
-- ^ More than 3 times the IQR above the third quartile.
|
||||
} deriving (Eq, Read, Show, Typeable, Data, Generic)
|
||||
|
||||
-instance Binary Outliers
|
||||
+instance Binary Outliers where
|
||||
+ put (Outliers a b c d e) = do
|
||||
+ put a
|
||||
+ put b
|
||||
+ put c
|
||||
+ put d
|
||||
+ put e
|
||||
+ get = Outliers <$> get <*> get <*> get <*> get <*> get
|
||||
instance NFData Outliers
|
||||
|
||||
-- | A description of the extent to which outliers in the sample data
|
||||
@@ -54,7 +63,19 @@
|
||||
-- are useless).
|
||||
deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)
|
||||
|
||||
-instance Binary OutlierEffect
|
||||
+instance Binary OutlierEffect where
|
||||
+ put Unaffected = put (0 :: Word8)
|
||||
+ put Slight = put (1 :: Word8)
|
||||
+ put Moderate = put (2 :: Word8)
|
||||
+ put Severe = put (3 :: Word8)
|
||||
+ get = do
|
||||
+ w <- get
|
||||
+ case w :: Word8 of
|
||||
+ 0 -> return Unaffected
|
||||
+ 1 -> return Slight
|
||||
+ 2 -> return Moderate
|
||||
+ 3 -> return Severe
|
||||
+ _ -> error "Binary.get for OutlierEffect failed"
|
||||
instance NFData OutlierEffect
|
||||
|
||||
instance Monoid Outliers where
|
||||
@@ -77,7 +98,9 @@
|
||||
-- ^ Quantitative description of effect (a fraction between 0 and 1).
|
||||
} deriving (Eq, Read, Show, Typeable, Data, Generic)
|
||||
|
||||
-instance Binary OutlierVariance
|
||||
+instance Binary OutlierVariance where
|
||||
+ put (OutlierVariance a b c) = put a >> put b >> put c
|
||||
+ get = OutlierVariance <$> get <*> get <*> get
|
||||
|
||||
instance NFData OutlierVariance where
|
||||
rnf OutlierVariance{..} = rnf ovEffect `seq` rnf ovDesc `seq` rnf ovFraction
|
||||
@@ -89,7 +112,9 @@
|
||||
, anOutlierVar :: OutlierVariance
|
||||
} deriving (Eq, Read, Show, Typeable, Data, Generic)
|
||||
|
||||
-instance Binary SampleAnalysis
|
||||
+instance Binary SampleAnalysis where
|
||||
+ put (SampleAnalysis a b c) = put a >> put b >> put c
|
||||
+ get = SampleAnalysis <$> get <*> get <*> get
|
||||
|
||||
instance NFData SampleAnalysis where
|
||||
rnf SampleAnalysis{..} =
|
||||
diff -ru orig/Criterion/IO.hs new/Criterion/IO.hs
|
||||
--- orig/Criterion/IO.hs 2014-04-10 08:02:35.383848688 +0300
|
||||
+++ new/Criterion/IO.hs 2014-04-10 08:02:34.000000000 +0300
|
||||
@@ -1,3 +1,4 @@
|
||||
+{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
-- |
|
||||
-- Module : Criterion.IO
|
||||
@@ -21,7 +22,11 @@
|
||||
|
||||
import Criterion.Types (ResultForest, ResultTree(..))
|
||||
import Data.Binary (Binary(..), encode)
|
||||
+#if MIN_VERSION_binary(0,6,3)
|
||||
import Data.Binary.Get (runGetOrFail)
|
||||
+#else
|
||||
+import Data.Binary.Get (runGetState)
|
||||
+#endif
|
||||
import Data.Binary.Put (putByteString, putWord16be, runPut)
|
||||
import Data.ByteString.Char8 ()
|
||||
import Data.Version (Version(..))
|
||||
@@ -58,6 +63,7 @@
|
||||
writeResults path rs = withFile path WriteMode (flip hPutResults rs)
|
||||
|
||||
readAll :: Binary a => Handle -> IO [a]
|
||||
+#if MIN_VERSION_binary(0,6,3)
|
||||
readAll handle = do
|
||||
let go bs
|
||||
| L.null bs = return []
|
||||
@@ -65,3 +71,12 @@
|
||||
Left (_, _, err) -> fail err
|
||||
Right (bs', _, a) -> (a:) `fmap` go bs'
|
||||
go =<< L.hGetContents handle
|
||||
+#else
|
||||
+readAll handle = do
|
||||
+ let go i bs
|
||||
+ | L.null bs = return []
|
||||
+ | otherwise =
|
||||
+ let (a, bs', i') = runGetState get bs i
|
||||
+ in (a:) `fmap` go i' bs'
|
||||
+ go 0 =<< L.hGetContents handle
|
||||
+#endif
|
||||
diff -ru orig/Criterion/Types.hs new/Criterion/Types.hs
|
||||
--- orig/Criterion/Types.hs 2014-04-10 08:02:35.383848688 +0300
|
||||
+++ new/Criterion/Types.hs 2014-04-10 08:02:34.000000000 +0300
|
||||
@@ -45,11 +45,13 @@
|
||||
, ResultTree(..)
|
||||
) where
|
||||
|
||||
+import Control.Applicative ((<$>), (<*>))
|
||||
import Control.DeepSeq (NFData, rnf)
|
||||
import Control.Exception (evaluate)
|
||||
import Criterion.Analysis.Types (Outliers(..), SampleAnalysis(..))
|
||||
-import Data.Binary (Binary)
|
||||
+import Data.Binary (Binary (get, put))
|
||||
import Data.Data (Data, Typeable)
|
||||
+import Data.Word (Word8)
|
||||
import GHC.Generics (Generic)
|
||||
import Statistics.Types (Sample)
|
||||
|
||||
@@ -161,11 +163,21 @@
|
||||
, outliers :: Outliers
|
||||
} deriving (Eq, Read, Show, Typeable, Data, Generic)
|
||||
|
||||
-instance Binary Result
|
||||
+instance Binary Result where
|
||||
+ put (Result a b c d) = put a >> put b >> put c >> put d
|
||||
+ get = Result <$> get <*> get <*> get <*> get
|
||||
|
||||
type ResultForest = [ResultTree]
|
||||
data ResultTree = Single Result
|
||||
| Compare !Int ResultForest
|
||||
deriving (Eq, Read, Show, Typeable, Data, Generic)
|
||||
|
||||
-instance Binary ResultTree
|
||||
+instance Binary ResultTree where
|
||||
+ put (Single x) = put (0 :: Word8) >> put x
|
||||
+ put (Compare x y) = put (1 :: Word8) >> put x >> put y
|
||||
+ get = do
|
||||
+ w <- get
|
||||
+ case w :: Word8 of
|
||||
+ 0 -> Single <$> get
|
||||
+ 1 -> Compare <$> get <*> get
|
||||
+ _ -> error "Binary.get for ResultTree failed"
|
||||
diff -ru orig/criterion.cabal new/criterion.cabal
|
||||
--- orig/criterion.cabal 2014-04-10 08:02:35.387848687 +0300
|
||||
+++ new/criterion.cabal 2014-04-10 08:02:34.000000000 +0300
|
||||
@@ -58,7 +58,7 @@
|
||||
build-depends:
|
||||
aeson >= 0.3.2.12,
|
||||
base < 5,
|
||||
- binary >= 0.6.3.0,
|
||||
+ binary >= 0.5.1,
|
||||
bytestring >= 0.9 && < 1.0,
|
||||
containers,
|
||||
deepseq >= 1.1.0.0,
|
||||
11
patching/patches/criterion-1.0.0.2.patch
Normal file
11
patching/patches/criterion-1.0.0.2.patch
Normal file
@ -0,0 +1,11 @@
|
||||
diff -ruN orig/criterion.cabal new/criterion.cabal
|
||||
--- orig/criterion.cabal 2014-08-10 16:13:33.958136765 +0300
|
||||
+++ new/criterion.cabal 2014-08-10 16:13:33.000000000 +0300
|
||||
@@ -131,6 +131,7 @@
|
||||
type: exitcode-stdio-1.0
|
||||
hs-source-dirs: tests
|
||||
main-is: Tests.hs
|
||||
+ other-modules: Properties
|
||||
|
||||
ghc-options:
|
||||
-Wall -threaded -O0 -rtsopts
|
||||
Loading…
Reference in New Issue
Block a user