summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-09-29 08:37:41 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-09-29 08:37:41 +0400
commitaec496291de09c0387d51a3ee1fbdb5927b19c15 (patch)
tree85895e2182431b97cac41fe221798d93c63ffec9 /bench
parentbb73c6aa23a05ad55432b869649c89e9eb656d6c (diff)
Rename decode and encode to mimic Binary package
This lead to more intuitive API.
Diffstat (limited to 'bench')
-rw-r--r--bench/Main.hs26
1 files changed, 13 insertions, 13 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index 1cd2429..d60c0d7 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -21,7 +21,7 @@ import "bencode" Data.BEncode as A
21import Data.AttoBencode as B 21import Data.AttoBencode as B
22import Data.AttoBencode.Parser as B 22import Data.AttoBencode.Parser as B
23import "bencoding" Data.BEncode as C 23import "bencoding" Data.BEncode as C
24 24import "bencoding" Data.BEncode.Internal as C
25 25
26instance NFData A.BEncode where 26instance NFData A.BEncode where
27 rnf (A.BInt i) = rnf i 27 rnf (A.BInt i) = rnf i
@@ -123,21 +123,21 @@ main = do
123 , bench "decode/AttoBencode" $ 123 , bench "decode/AttoBencode" $
124 nf (getRight . Atto.parseOnly bValue) torrentFile 124 nf (getRight . Atto.parseOnly bValue) torrentFile
125 , bench "decode/bencoding" $ 125 , bench "decode/bencoding" $
126 nf (getRight . C.decode) torrentFile 126 nf (getRight . C.parse) torrentFile
127 127
128 , let Just v = A.bRead lazyTorrentFile in 128 , let Just v = A.bRead lazyTorrentFile in
129 bench "encode/bencode" $ nf A.bPack v 129 bench "encode/bencode" $ nf A.bPack v
130 , let Right v = Atto.parseOnly bValue torrentFile in 130 , let Right v = Atto.parseOnly bValue torrentFile in
131 bench "encode/AttoBencode" $ nf B.encode v 131 bench "encode/AttoBencode" $ nf B.encode v
132 , let Right v = C.decode torrentFile in 132 , let Right v = C.parse torrentFile in
133 bench "encode/bencoding" $ nf C.encode v 133 bench "encode/bencoding" $ nf C.build v
134 134
135 , bench "decode+encode/bencode" $ 135 , bench "decode+encode/bencode" $
136 nf (A.bPack . fromJust . A.bRead) lazyTorrentFile 136 nf (A.bPack . fromJust . A.bRead) lazyTorrentFile
137 , bench "decode+encode/AttoBencode" $ 137 , bench "decode+encode/AttoBencode" $
138 nf (B.encode . getRight . Atto.parseOnly bValue) torrentFile 138 nf (B.encode . getRight . Atto.parseOnly bValue) torrentFile
139 , bench "decode+encode/bencoding" $ 139 , bench "decode+encode/bencoding" $
140 nf (C.encode . getRight . C.decode) torrentFile 140 nf (C.build . getRight . C.parse) torrentFile
141 141
142 , bench "list10000int/bencode/encode" $ 142 , bench "list10000int/bencode/encode" $
143 nf (A.bPack . A.BList . L.map (A.BInt . fromIntegral)) 143 nf (A.bPack . A.BList . L.map (A.BInt . fromIntegral))
@@ -146,7 +146,7 @@ main = do
146 , bench "list10000int/attobencode/encode" $ 146 , bench "list10000int/attobencode/encode" $
147 nf B.encode [1..20000 :: Int] 147 nf B.encode [1..20000 :: Int]
148 , bench "list10000int/bencoding/encode" $ 148 , bench "list10000int/bencoding/encode" $
149 nf C.encoded [1..20000 :: Int] 149 nf C.encode [1..20000 :: Int]
150 150
151 151
152 , let d = A.bPack $ A.BList $ 152 , let d = A.bPack $ A.BList $
@@ -154,27 +154,27 @@ main = do
154 in d `seq` (bench "list1000int/bencode/decode" $ nf 154 in d `seq` (bench "list1000int/bencode/decode" $ nf
155 (fromJust . A.bRead :: BL.ByteString -> A.BEncode) d) 155 (fromJust . A.bRead :: BL.ByteString -> A.BEncode) d)
156 156
157 , let d = BL.toStrict (C.encoded (L.replicate 10000 ())) 157 , let d = BL.toStrict (C.encode (L.replicate 10000 ()))
158 in d `seq` (bench "list10000unit/bencoding/decode" $ nf 158 in d `seq` (bench "list10000unit/bencoding/decode" $ nf
159 (C.decoded :: BS.ByteString -> Either String [()]) d) 159 (C.decode :: BS.ByteString -> Either String [()]) d)
160 160
161 , let d = BL.toStrict $ C.encoded $ L.replicate 10000 (0 :: Int) 161 , let d = BL.toStrict $ C.encode $ L.replicate 10000 (0 :: Int)
162 in d `seq` (bench "list10000int/bencoding/decode" $ nf 162 in d `seq` (bench "list10000int/bencoding/decode" $ nf
163 (C.decoded :: BS.ByteString -> Either String [Int]) d) 163 (C.decode :: BS.ByteString -> Either String [Int]) d)
164 164
165 , let d = L.replicate 10000 0 165 , let d = L.replicate 10000 0
166 in bench "list10000int/bencoding/encode>>decode" $ 166 in bench "list10000int/bencoding/encode>>decode" $
167 nf (getRight . C.decoded . BL.toStrict . C.encoded 167 nf (getRight . C.decode . BL.toStrict . C.encode
168 :: [Int] -> [Int] ) 168 :: [Int] -> [Int] )
169 d 169 d
170 170
171 , let d = replicate' 10000 0 171 , let d = replicate' 10000 0
172 in bench "list10000int/bencoding/encode>>decode/generic" $ 172 in bench "list10000int/bencoding/encode>>decode/generic" $
173 nf (getRight . C.decoded . BL.toStrict . C.encoded 173 nf (getRight . C.decode . BL.toStrict . C.encode
174 :: List Int -> List Int) 174 :: List Int -> List Int)
175 d 175 d
176 176
177 , let Right be = C.decode torrentFile 177 , let Right be = C.parse torrentFile
178 id' x = let t = either error id (fromBEncode x) 178 id' x = let t = either error id (fromBEncode x)
179 in toBEncode (t :: Torrent) 179 in toBEncode (t :: Torrent)
180 180