diff options
Diffstat (limited to 'bench/Main.hs')
-rw-r--r-- | bench/Main.hs | 21 |
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) | |||
33 | decodeMessages :: ByteString -> Either String [Message] | 33 | decodeMessages :: ByteString -> Either String [Message] |
34 | decodeMessages = runGet (many get) | 34 | decodeMessages = runGet (many get) |
35 | 35 | ||
36 | bitfieldDiff :: Int -> Bitfield | ||
37 | bitfieldDiff n = BT.empty n `difference` BT.empty n | ||
38 | |||
39 | bitfieldMin :: Int -> Maybe Int | 36 | bitfieldMin :: Int -> Maybe Int |
40 | bitfieldMin n = findMin (BT.empty n) | 37 | bitfieldMin n = findMin (BT.empty n) |
41 | 38 | ||
42 | bitfieldMax :: Int -> Maybe Int | 39 | bitfieldMax :: Int -> Maybe Int |
43 | bitfieldMax n = findMax (BT.empty n) | 40 | bitfieldMax n = findMax (BT.empty n) |
44 | 41 | ||
42 | bitfieldDiff :: Int -> Bitfield | ||
43 | bitfieldDiff n = BT.empty n `difference` BT.empty n | ||
44 | |||
45 | bitfieldInter :: Int -> Bitfield | ||
46 | bitfieldInter n = BT.empty n `intersection` BT.empty n | ||
47 | |||
48 | bitfieldUnion :: Int -> Bitfield | ||
49 | bitfieldUnion n = BT.empty n `union` BT.empty n | ||
50 | |||
51 | |||
45 | main :: IO () | 52 | main :: IO () |
46 | main = do | 53 | main = 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 |