Commits

Bryan O'Sullivan committed d035ce5

Basic creation benchmark

Comments (0)

Files changed (3)

-^dist/
 ~$
 
 syntax: glob
 
+dist
 *.[aos]
 *.hi
 *.p_hi

benchmarks/Benchmarks.hs

+{-# 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
+      ]
+    ]

benchmarks/bloomfilter-benchmarks.cabal

+name:           bloomfilter-benchmarks
+version:        0
+license:        BSD3
+author:         Bryan O'Sullivan
+maintainer:     bos@serpentine.com
+copyright:      2012 Bryan O'Sullivan
+category:       Data
+build-type:     Simple
+cabal-version:  >=1.8
+
+flag debug
+  description:  Enable debug support
+  default:      False
+
+executable bloomfilter-benchmarks
+  main-is: Benchmarks.hs
+
+  build-depends:
+    base,
+    bloomfilter,
+    bytestring,
+    containers,
+    criterion,
+    deepseq >= 1.1,
+    mtl,
+    random
+
+  ghc-options: -Wall -O2 -rtsopts
+  if impl(ghc >= 6.8)
+    ghc-options: -fwarn-tabs
+  if impl(ghc > 6.10)
+    ghc-options: -fregs-graph
+  if flag(debug)
+    cpp-options: -DASSERTS
+
+  if impl(ghc < 7.4)
+    c-sources: ../cbits/popc.c