diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-10-31 11:25:59 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-10-31 11:25:59 +0400 |
commit | 01cef3fafc27d39d88c94cacdcd8e204c5f66b86 (patch) | |
tree | 01040aca19e49f4e7937383fef53b8c82bcec12b /bench | |
parent | c1fec260f47084300ac30de2e43d52966316a2c7 (diff) |
Merge bittorrent package with torrent-content
Diffstat (limited to 'bench')
-rw-r--r-- | bench/TorrentFile.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bench/TorrentFile.hs b/bench/TorrentFile.hs new file mode 100644 index 00000000..e91a9c10 --- /dev/null +++ b/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 | ||