File: Sets.hs

package info (click to toggle)
haskell-attoparsec 0.14.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 880 kB
  • sloc: haskell: 4,749; ansic: 170; makefile: 22
file content (21 lines) | stat: -rw-r--r-- 731 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Sets (benchmarks) where

import Test.Tasty.Bench
import Data.Char (ord)
import qualified Data.Attoparsec.Text.FastSet as FastSet
import qualified TextFastSet
import qualified Data.HashSet as HashSet
import qualified Data.IntSet as IntSet

smallSet :: String
smallSet = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9']

benchmarks :: Benchmark
benchmarks = bgroup "sets" [
    bench "Fast" $ whnf (FastSet.member '*') (FastSet.fromList smallSet)
  , bench "Hash" $ whnf (HashSet.member '*') (HashSet.fromList smallSet)
  , bench "Int" $ whnf (IntSet.member (ord '*'))
                  (IntSet.fromList (map ord smallSet))
  , bench "TextFast" $ whnf (TextFastSet.member '*')
                       (TextFastSet.fromList smallSet)
  ]