Source

bloomfilter / benchmarks / Benchmarks.hs

The default branch has multiple heads

{-# OPTIONS_GHC -fno-warn-orphans #-}

module Main (main) where

import Control.Monad.Trans
import Control.Exception (evaluate)
import Control.DeepSeq
import Criterion.Main
import Criterion.Config
import Data.BloomFilter.Easy
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (ByteString(..))

instance NFData ByteString where
    rnf (PS _ _ _) = ()

main :: IO ()
main = do
  ws <- B.lines `fmap` B.readFile "/usr/share/dict/words"
  defaultMainWith defaultConfig
    (liftIO . evaluate . rnf $ ws)
    [
      bgroup "create" [
        bench "easy" $ whnf (easyList 0.01) ws
      ]
    ]