summaryrefslogtreecommitdiff
path: root/bench/TorrentFile.hs
blob: e91a9c10e97ebbeed8dd37830005414c8cdb0a4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE BangPatterns #-}
module Main (main) where

import Data.BEncode
import Data.ByteString as BS
import Data.Torrent
import Criterion.Main


tinyPath :: FilePath
tinyPath = "res/dapper-dvd-amd64.iso.torrent"

largePath :: FilePath
largePath = "res/pkg.torrent"

decoder :: ByteString -> Torrent
decoder bs = let Right r = decode bs in r

main :: IO ()
main = do
  !tinyBin  <- BS.readFile tinyPath
  !largeBin <- BS.readFile largePath

  defaultMain
    [ bench "read/tiny"  $ nf decoder tinyBin
    , bench "read/large" $ nf decoder largeBin
    ]