diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-08-26 21:08:29 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-08-26 21:08:29 +0400 |
commit | 2dd7c644253beb50fd8a2256bba5bff7e32c0978 (patch) | |
tree | eba3f61c620cb1f7856a7af4ce4a99e249b5e0c9 /bench | |
parent | 1c7601a6cca488202abb24578ac9163029f381ab (diff) |
~ Obey 80 column rule.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/Main.hs | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/bench/Main.hs b/bench/Main.hs index 20de179..db9b47c 100644 --- a/bench/Main.hs +++ b/bench/Main.hs | |||
@@ -15,6 +15,7 @@ import Data.AttoBencode as B | |||
15 | import Data.AttoBencode.Parser as B | 15 | import Data.AttoBencode.Parser as B |
16 | import "bencoding" Data.BEncode as C | 16 | import "bencoding" Data.BEncode as C |
17 | 17 | ||
18 | |||
18 | instance NFData A.BEncode where | 19 | instance NFData A.BEncode where |
19 | rnf (A.BInt i) = rnf i | 20 | rnf (A.BInt i) = rnf i |
20 | rnf (A.BString s) = rnf s | 21 | rnf (A.BString s) = rnf s |
@@ -41,9 +42,12 @@ main = do | |||
41 | 42 | ||
42 | withArgs args $ | 43 | withArgs args $ |
43 | defaultMain | 44 | defaultMain |
44 | [ bench "decode/bencode" $ nf A.bRead lazyTorrentFile | 45 | [ bench "decode/bencode" $ |
45 | , bench "decode/AttoBencode" $ nf (getRight . Atto.parseOnly bValue) torrentFile | 46 | nf A.bRead lazyTorrentFile |
46 | , bench "decode/bencoding" $ nf (getRight . C.decode) torrentFile | 47 | , bench "decode/AttoBencode" $ |
48 | nf (getRight . Atto.parseOnly bValue) torrentFile | ||
49 | , bench "decode/bencoding" $ | ||
50 | nf (getRight . C.decode) torrentFile | ||
47 | 51 | ||
48 | , let Just v = A.bRead lazyTorrentFile in | 52 | , let Just v = A.bRead lazyTorrentFile in |
49 | bench "encode/bencode" $ nf A.bPack v | 53 | bench "encode/bencode" $ nf A.bPack v |
@@ -52,19 +56,21 @@ main = do | |||
52 | , let Right v = C.decode torrentFile in | 56 | , let Right v = C.decode torrentFile in |
53 | bench "encode/bencoding" $ nf C.encode v | 57 | bench "encode/bencoding" $ nf C.encode v |
54 | 58 | ||
55 | , bench "decode+encode/bencode" $ nf (A.bPack . fromJust . A.bRead) | 59 | , bench "decode+encode/bencode" $ |
56 | lazyTorrentFile | 60 | nf (A.bPack . fromJust . A.bRead) lazyTorrentFile |
57 | , bench "decode+encode/AttoBencode" $ nf (B.encode . getRight . Atto.parseOnly bValue) | 61 | , bench "decode+encode/AttoBencode" $ |
58 | torrentFile | 62 | nf (B.encode . getRight . Atto.parseOnly bValue) torrentFile |
59 | , bench "decode+encode/bencoding" $ nf (C.encode . getRight . C.decode) | 63 | , bench "decode+encode/bencoding" $ |
60 | torrentFile | 64 | nf (C.encode . getRight . C.decode) torrentFile |
61 | 65 | ||
62 | , bench "list10000int/bencode/encode" $ nf | 66 | , bench "list10000int/bencode/encode" $ |
63 | (A.bPack . A.BList . L.map (A.BInt . fromIntegral)) | 67 | nf (A.bPack . A.BList . L.map (A.BInt . fromIntegral)) |
64 | [0..10000 :: Int] | 68 | [0..10000 :: Int] |
65 | 69 | ||
66 | , bench "list10000int/attobencode/encode" $ nf B.encode [1..20000 :: Int] | 70 | , bench "list10000int/attobencode/encode" $ |
67 | , bench "list10000int/bencoding/encode" $ nf C.encoded [1..20000 :: Int] | 71 | nf B.encode [1..20000 :: Int] |
72 | , bench "list10000int/bencoding/encode" $ | ||
73 | nf C.encoded [1..20000 :: Int] | ||
68 | 74 | ||
69 | 75 | ||
70 | , let d = A.bPack $ A.BList $ | 76 | , let d = A.bPack $ A.BList $ |
@@ -81,6 +87,8 @@ main = do | |||
81 | (C.decoded :: B.ByteString -> Either String [Int]) d) | 87 | (C.decoded :: B.ByteString -> Either String [Int]) d) |
82 | 88 | ||
83 | , let d = L.replicate 10000 0 | 89 | , let d = L.replicate 10000 0 |
84 | in bench "list10000int/bencoding/encode>>decode" $ nf | 90 | in bench "list10000int/bencoding/encode>>decode" $ |
85 | (getRight . C.decoded . BL.toStrict . C.encoded :: [Int] -> [Int] ) d | 91 | nf (getRight . C.decoded . BL.toStrict . C.encoded |
92 | :: [Int] -> [Int] ) | ||
93 | d | ||
86 | ] | 94 | ] |