summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-05-19 17:08:47 +0400
committerSam T <pxqr.sta@gmail.com>2013-05-19 17:08:47 +0400
commitc2e98a5a1c920fb1af023228a873249e9f2f2ef5 (patch)
treee5848c232c3a5c7ef5ca9f1e6842456f93c16401 /bench
parent6c0d145b82a6372ba98c60f3bf398f8da8a8c89b (diff)
+ Add benchmarks for long int lists.
Diffstat (limited to 'bench')
-rw-r--r--bench/Main.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index cc64d4b..08ebab8 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -6,6 +6,7 @@ import Data.Maybe
6import Data.Attoparsec.ByteString as Atto 6import Data.Attoparsec.ByteString as Atto
7import Data.ByteString as B 7import Data.ByteString as B
8import Data.ByteString.Lazy as BL 8import Data.ByteString.Lazy as BL
9import Data.List as L
9import Criterion.Main 10import Criterion.Main
10import System.Environment 11import System.Environment
11 12
@@ -64,4 +65,26 @@ main = do
64 torrentFile 65 torrentFile
65 , bench "decode+encode/bencoding" $ nf (C.encode . getRight . C.decode) 66 , bench "decode+encode/bencoding" $ nf (C.encode . getRight . C.decode)
66 torrentFile 67 torrentFile
68
69 , bench "list10000int/bencode/encode" $ nf
70 (A.bPack . A.BList . L.map (A.BInt . fromIntegral))
71 [0..10000 :: Int]
72
73 , bench "list10000int/attobencode/encode" $ nf B.encode [1..20000 :: Int]
74 , bench "list10000int/bencoding/encode" $ nf C.encoded [1..20000 :: Int]
75
76
77 , let d = A.bPack $ A.BList $
78 L.map A.BInt (L.replicate 1000 (0 :: Integer))
79 in d `seq` (bench "list10000int/bencode/decode" $ nf
80 (fromJust . A.bRead :: BL.ByteString -> A.BEncode) d)
81
82 , let d = BL.toStrict (C.encoded (L.replicate 10000 ()))
83 in d `seq` (bench "list10000unit/bencoding/decode" $ nf
84 (C.decoded :: B.ByteString -> Either String [()]) d)
85
86 , let d = BL.toStrict (C.encoded (L.replicate 10000 (0 :: Int)))
87 in d `seq` (bench "list10000int/bencoding/decode" $ nf
88 (C.decoded :: B.ByteString -> Either String [Int]) d)
89
67 ] 90 ]