git.iko.soy/typeable/attoparsec
on master help sign in
Add benchmarks for set membership performance

FastSet wins, but the implementation appears to be broken under GHC 7.10 (maybe others too)

commit56a846acf93e53c3d97f2f24ddd1269f14fa3e6e authorBryan O'Sullivan <bos@serpentine.com> dateWed 8 Jul 2015, 16:51 (11 years ago) parentd21af97
4 files changed+23
attoparsec.cabal+1 benchmarks/Benchmarks.hs+2 benchmarks/Sets.hs+18 benchmarks/attoparsec-benchmarks.cabal+2
attoparsec.cabal+1
@@ -122,6 +122,7 @@ benchmark benchmarks
122122 HeadersText
123123 Links
124124 Numbers
125+ Sets
125126 Warp
126127 ghc-options: -O2 -Wall
127128
benchmarks/Benchmarks.hs+2
@@ -28,6 +28,7 @@ import qualified HeadersByteString
2828import qualified HeadersText
2929import qualified Links
3030import qualified Text.Parsec as P
31+import qualified Sets
3132
3233main :: IO ()
3334main = do
@@ -86,6 +87,7 @@ main = do
8687 , headersT
8788 , Links.links
8889 , numbers
90+ , Sets.benchmarks
8991 , Warp.benchmarks
9092 ]
9193
benchmarks/Sets.hsnew file+18
@@ -0,0 +1,18 @@
1+module Sets (benchmarks) where
2+
3+import Criterion
4+import Data.Char (ord)
5+import qualified Data.Attoparsec.Text.FastSet as FastSet
6+import qualified Data.HashSet as HashSet
7+import qualified Data.IntSet as IntSet
8+
9+smallSet :: String
10+smallSet = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9']
11+
12+benchmarks :: Benchmark
13+benchmarks = bgroup "sets" [
14+ bench "Fast" $ whnf (FastSet.member '*') (FastSet.fromList smallSet)
15+ , bench "HashSet" $ whnf (HashSet.member '*') (HashSet.fromList smallSet)
16+ , bench "IntSet" $ whnf (IntSet.member (ord '*'))
17+ (IntSet.fromList (map ord smallSet))
18+ ]
benchmarks/attoparsec-benchmarks.cabal+2
@@ -16,6 +16,7 @@ executable attoparsec-benchmarks
1616 Links
1717 Numbers
1818 Network.Wai.Handler.Warp.ReadInt
19+ Sets
1920 Warp
2021 hs-source-dirs: .. . warp-3.0.1.1
2122 ghc-options: -O2 -Wall -rtsopts
@@ -24,6 +25,7 @@ executable attoparsec-benchmarks
2425 base == 4.*,
2526 bytestring >= 0.10.4.0,
2627 case-insensitive,
28+ containers,
2729 criterion >= 1.0,
2830 deepseq >= 1.1,
2931 directory,