diff options
Diffstat (limited to 'bittorrent/bench/TorrentFile.hs')
-rw-r--r-- | bittorrent/bench/TorrentFile.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bittorrent/bench/TorrentFile.hs b/bittorrent/bench/TorrentFile.hs new file mode 100644 index 00000000..e91a9c10 --- /dev/null +++ b/bittorrent/bench/TorrentFile.hs | |||
@@ -0,0 +1,27 @@ | |||
1 | {-# LANGUAGE BangPatterns #-} | ||
2 | module Main (main) where | ||
3 | |||
4 | import Data.BEncode | ||
5 | import Data.ByteString as BS | ||
6 | import Data.Torrent | ||
7 | import Criterion.Main | ||
8 | |||
9 | |||
10 | tinyPath :: FilePath | ||
11 | tinyPath = "res/dapper-dvd-amd64.iso.torrent" | ||
12 | |||
13 | largePath :: FilePath | ||
14 | largePath = "res/pkg.torrent" | ||
15 | |||
16 | decoder :: ByteString -> Torrent | ||
17 | decoder bs = let Right r = decode bs in r | ||
18 | |||
19 | main :: IO () | ||
20 | main = do | ||
21 | !tinyBin <- BS.readFile tinyPath | ||
22 | !largeBin <- BS.readFile largePath | ||
23 | |||
24 | defaultMain | ||
25 | [ bench "read/tiny" $ nf decoder tinyBin | ||
26 | , bench "read/large" $ nf decoder largeBin | ||
27 | ] \ No newline at end of file | ||