on master help sign in
Updated criterion patch
commite60838e986c669b82c3d4c9770706d532563cab7 authorMichael Snoyman <michael@snoyman.com> dateThu 10 Apr 2014, 08:02 (13 years ago) parent4f830f8
2 files changed+171−55
patching/patches/criterion-0.8.0.1.patch−55 patching/patches/criterion-0.8.0.2.patch+171
patching/patches/criterion-0.8.0.1.patchdeleted−55
@@ -1,55 +0,0 @@
1−diff -ru orig/Criterion/IO.hs new/Criterion/IO.hs
2−--- orig/Criterion/IO.hs 2014-02-21 06:51:14.286525542 +0200
3−+++ new/Criterion/IO.hs 2014-02-21 06:51:14.000000000 +0200
4−@@ -1,4 +1,5 @@
5− {-# LANGUAGE OverloadedStrings #-}
6−+{-# LANGUAGE CPP #-}
7− -- |
8− -- Module : Criterion.IO
9− -- Copyright : (c) 2009, 2010 Bryan O'Sullivan
10−@@ -21,7 +22,11 @@
11−
12− import Criterion.Types (ResultForest, ResultTree(..))
13− import Data.Binary (Binary(..), encode)
14−+#if MIN_VERSION_binary(0, 6, 3)
15− import Data.Binary.Get (runGetOrFail)
16−+#else
17−+import Data.Binary.Get (runGetState)
18−+#endif
19− import Data.Binary.Put (putByteString, putWord16be, runPut)
20− import Data.Version (Version(..))
21− import Paths_criterion (version)
22−@@ -56,6 +61,7 @@
23− writeResults :: FilePath -> ResultForest -> IO ()
24− writeResults path rs = withFile path WriteMode (flip hPutResults rs)
25−
26−+#if MIN_VERSION_binary(0, 6, 3)
27− readAll :: Binary a => Handle -> IO [a]
28− readAll handle = do
29− let go bs
30−@@ -64,3 +70,13 @@
31− Left (_, _, err) -> fail err
32− Right (bs', _, a) -> (a:) `fmap` go bs'
33− go =<< L.hGetContents handle
34−+#else
35−+readAll :: Binary a => Handle -> IO [a]
36−+readAll handle = do
37−+ let go i bs
38−+ | L.null bs = return []
39−+ | otherwise =
40−+ let (a, bs', i') = runGetState get bs i
41−+ in (a:) `fmap` go i' bs'
42−+ go 0 =<< L.hGetContents handle
43−+#endif
44−diff -ru orig/criterion.cabal new/criterion.cabal
45−--- orig/criterion.cabal 2014-02-21 06:51:14.314525543 +0200
46−+++ new/criterion.cabal 2014-02-21 06:51:14.000000000 +0200
47−@@ -58,7 +58,7 @@
48− build-depends:
49− aeson >= 0.3.2.12,
50− base < 5,
51−- binary >= 0.6.3.0,
52−+ binary >= 0.5.1.0,
53− bytestring >= 0.9 && < 1.0,
54− containers,
55− deepseq >= 1.1.0.0,
patching/patches/criterion-0.8.0.2.patchnew file+171
@@ -0,0 +1,171 @@
1+diff -ru orig/Criterion/Analysis/Types.hs new/Criterion/Analysis/Types.hs
2+--- orig/Criterion/Analysis/Types.hs 2014-04-10 08:02:35.383848688 +0300
3++++ new/Criterion/Analysis/Types.hs 2014-04-10 08:02:34.000000000 +0300
4+@@ -19,10 +19,12 @@
5+ , SampleAnalysis(..)
6+ ) where
7+
8++import Control.Applicative ((<$>), (<*>))
9+ import Control.DeepSeq (NFData(rnf))
10+-import Data.Binary (Binary)
11++import Data.Binary (Binary, put, get)
12+ import Data.Data (Data, Typeable)
13+ import Data.Int (Int64)
14++import Data.Word (Word8)
15+ import Data.Monoid (Monoid(..))
16+ import GHC.Generics (Generic)
17+ import qualified Statistics.Resampling.Bootstrap as B
18+@@ -42,7 +44,14 @@
19+ -- ^ More than 3 times the IQR above the third quartile.
20+ } deriving (Eq, Read, Show, Typeable, Data, Generic)
21+
22+-instance Binary Outliers
23++instance Binary Outliers where
24++ put (Outliers a b c d e) = do
25++ put a
26++ put b
27++ put c
28++ put d
29++ put e
30++ get = Outliers <$> get <*> get <*> get <*> get <*> get
31+ instance NFData Outliers
32+
33+ -- | A description of the extent to which outliers in the sample data
34+@@ -54,7 +63,19 @@
35+ -- are useless).
36+ deriving (Eq, Ord, Read, Show, Typeable, Data, Generic)
37+
38+-instance Binary OutlierEffect
39++instance Binary OutlierEffect where
40++ put Unaffected = put (0 :: Word8)
41++ put Slight = put (1 :: Word8)
42++ put Moderate = put (2 :: Word8)
43++ put Severe = put (3 :: Word8)
44++ get = do
45++ w <- get
46++ case w :: Word8 of
47++ 0 -> return Unaffected
48++ 1 -> return Slight
49++ 2 -> return Moderate
50++ 3 -> return Severe
51++ _ -> error "Binary.get for OutlierEffect failed"
52+ instance NFData OutlierEffect
53+
54+ instance Monoid Outliers where
55+@@ -77,7 +98,9 @@
56+ -- ^ Quantitative description of effect (a fraction between 0 and 1).
57+ } deriving (Eq, Read, Show, Typeable, Data, Generic)
58+
59+-instance Binary OutlierVariance
60++instance Binary OutlierVariance where
61++ put (OutlierVariance a b c) = put a >> put b >> put c
62++ get = OutlierVariance <$> get <*> get <*> get
63+
64+ instance NFData OutlierVariance where
65+ rnf OutlierVariance{..} = rnf ovEffect `seq` rnf ovDesc `seq` rnf ovFraction
66+@@ -89,7 +112,9 @@
67+ , anOutlierVar :: OutlierVariance
68+ } deriving (Eq, Read, Show, Typeable, Data, Generic)
69+
70+-instance Binary SampleAnalysis
71++instance Binary SampleAnalysis where
72++ put (SampleAnalysis a b c) = put a >> put b >> put c
73++ get = SampleAnalysis <$> get <*> get <*> get
74+
75+ instance NFData SampleAnalysis where
76+ rnf SampleAnalysis{..} =
77+diff -ru orig/Criterion/IO.hs new/Criterion/IO.hs
78+--- orig/Criterion/IO.hs 2014-04-10 08:02:35.383848688 +0300
79++++ new/Criterion/IO.hs 2014-04-10 08:02:34.000000000 +0300
80+@@ -1,3 +1,4 @@
81++{-# LANGUAGE CPP #-}
82+ {-# LANGUAGE OverloadedStrings #-}
83+ -- |
84+ -- Module : Criterion.IO
85+@@ -21,7 +22,11 @@
86+
87+ import Criterion.Types (ResultForest, ResultTree(..))
88+ import Data.Binary (Binary(..), encode)
89++#if MIN_VERSION_binary(0,6,3)
90+ import Data.Binary.Get (runGetOrFail)
91++#else
92++import Data.Binary.Get (runGetState)
93++#endif
94+ import Data.Binary.Put (putByteString, putWord16be, runPut)
95+ import Data.ByteString.Char8 ()
96+ import Data.Version (Version(..))
97+@@ -58,6 +63,7 @@
98+ writeResults path rs = withFile path WriteMode (flip hPutResults rs)
99+
100+ readAll :: Binary a => Handle -> IO [a]
101++#if MIN_VERSION_binary(0,6,3)
102+ readAll handle = do
103+ let go bs
104+ | L.null bs = return []
105+@@ -65,3 +71,12 @@
106+ Left (_, _, err) -> fail err
107+ Right (bs', _, a) -> (a:) `fmap` go bs'
108+ go =<< L.hGetContents handle
109++#else
110++readAll handle = do
111++ let go i bs
112++ | L.null bs = return []
113++ | otherwise =
114++ let (a, bs', i') = runGetState get bs i
115++ in (a:) `fmap` go i' bs'
116++ go 0 =<< L.hGetContents handle
117++#endif
118+diff -ru orig/Criterion/Types.hs new/Criterion/Types.hs
119+--- orig/Criterion/Types.hs 2014-04-10 08:02:35.383848688 +0300
120++++ new/Criterion/Types.hs 2014-04-10 08:02:34.000000000 +0300
121+@@ -45,11 +45,13 @@
122+ , ResultTree(..)
123+ ) where
124+
125++import Control.Applicative ((<$>), (<*>))
126+ import Control.DeepSeq (NFData, rnf)
127+ import Control.Exception (evaluate)
128+ import Criterion.Analysis.Types (Outliers(..), SampleAnalysis(..))
129+-import Data.Binary (Binary)
130++import Data.Binary (Binary (get, put))
131+ import Data.Data (Data, Typeable)
132++import Data.Word (Word8)
133+ import GHC.Generics (Generic)
134+ import Statistics.Types (Sample)
135+
136+@@ -161,11 +163,21 @@
137+ , outliers :: Outliers
138+ } deriving (Eq, Read, Show, Typeable, Data, Generic)
139+
140+-instance Binary Result
141++instance Binary Result where
142++ put (Result a b c d) = put a >> put b >> put c >> put d
143++ get = Result <$> get <*> get <*> get <*> get
144+
145+ type ResultForest = [ResultTree]
146+ data ResultTree = Single Result
147+ | Compare !Int ResultForest
148+ deriving (Eq, Read, Show, Typeable, Data, Generic)
149+
150+-instance Binary ResultTree
151++instance Binary ResultTree where
152++ put (Single x) = put (0 :: Word8) >> put x
153++ put (Compare x y) = put (1 :: Word8) >> put x >> put y
154++ get = do
155++ w <- get
156++ case w :: Word8 of
157++ 0 -> Single <$> get
158++ 1 -> Compare <$> get <*> get
159++ _ -> error "Binary.get for ResultTree failed"
160+diff -ru orig/criterion.cabal new/criterion.cabal
161+--- orig/criterion.cabal 2014-04-10 08:02:35.387848687 +0300
162++++ new/criterion.cabal 2014-04-10 08:02:34.000000000 +0300
163+@@ -58,7 +58,7 @@
164+ build-depends:
165+ aeson >= 0.3.2.12,
166+ base < 5,
167+- binary >= 0.6.3.0,
168++ binary >= 0.5.1,
169+ bytestring >= 0.9 && < 1.0,
170+ containers,
171+ deepseq >= 1.1.0.0,