summaryrefslogtreecommitdiff
path: root/bench/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'bench/Main.hs')
-rw-r--r--bench/Main.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index 4ce7c818..59cb9ea7 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -33,15 +33,22 @@ encodeMessages xs = runPut (mapM_ put xs)
33decodeMessages :: ByteString -> Either String [Message] 33decodeMessages :: ByteString -> Either String [Message]
34decodeMessages = runGet (many get) 34decodeMessages = runGet (many get)
35 35
36bitfieldDiff :: Int -> Bitfield
37bitfieldDiff n = BT.empty n `difference` BT.empty n
38
39bitfieldMin :: Int -> Maybe Int 36bitfieldMin :: Int -> Maybe Int
40bitfieldMin n = findMin (BT.empty n) 37bitfieldMin n = findMin (BT.empty n)
41 38
42bitfieldMax :: Int -> Maybe Int 39bitfieldMax :: Int -> Maybe Int
43bitfieldMax n = findMax (BT.empty n) 40bitfieldMax n = findMax (BT.empty n)
44 41
42bitfieldDiff :: Int -> Bitfield
43bitfieldDiff n = BT.empty n `difference` BT.empty n
44
45bitfieldInter :: Int -> Bitfield
46bitfieldInter n = BT.empty n `intersection` BT.empty n
47
48bitfieldUnion :: Int -> Bitfield
49bitfieldUnion n = BT.empty n `union` BT.empty n
50
51
45main :: IO () 52main :: IO ()
46main = do 53main = do
47 let datas = replicate 10000 (Request (BlockIx 0 0 0)) 54 let datas = replicate 10000 (Request (BlockIx 0 0 0))
@@ -51,7 +58,9 @@ main = do
51 , let binary = encodeMessages datas in 58 , let binary = encodeMessages datas in
52 binary `deepseq` bench "message/decode" $ nf decodeMessages binary 59 binary `deepseq` bench "message/decode" $ nf decodeMessages binary
53 60
54 , bench "bitfield/difference" $ nf bitfieldDiff 1000000 61 , bench "bitfield/min" $ nf bitfieldMin 10000000
55 , bench "bitfield/min" $ nf bitfieldMin 10000000 62 , bench "bitfield/max" $ nf bitfieldMax 10000000
56 , bench "bitfield/max" $ nf bitfieldMax 10000000 63 , bench "bitfield/difference" $ nf bitfieldDiff 1000000
64 , bench "bitfield/intersection" $ nf bitfieldInter 1000000
65 , bench "bitfield/union" $ nf bitfieldUnion 1000000
57 ] \ No newline at end of file 66 ] \ No newline at end of file