diff --git a/uuid-types/tests/BenchUUID.hs b/uuid-types/tests/BenchUUID.hs index c4bebc7..7445a66 100644 --- a/uuid-types/tests/BenchUUID.hs +++ b/uuid-types/tests/BenchUUID.hs @@ -8,6 +8,7 @@ import qualified Data.ByteString.Lazy.Internal as BL import Criterion.Main import Data.Maybe (fromJust) import qualified Data.Set as Set +import qualified Data.HashSet as HashSet import qualified Data.ByteString.Lazy as BL import qualified Data.UUID.Types as U import Foreign (alloca, peek, poke) @@ -24,6 +25,9 @@ main = do u1 <- randomIO let s1 = U.toString u1 b1 = U.toByteString u1 + a1 = U.toASCIIBytes u1 + t1 = U.toText u1 + (w1a,w1b,w1c,w1d) = U.toWords u1 nil2 = fromJust $ U.fromString "00000000-0000-0000-0000-000000000000" u2a = fromJust $ U.fromString "169a5a43-c051-4a16-98f4-08447ddd5dc0" @@ -43,15 +47,25 @@ main = do bench "null nil" $ whnf U.null U.nil, bench "null nil2" $ whnf U.null nil2, bench "eq same" $ whnf (==u2a) u2b, - bench "eq differ" $ whnf (==u2a) u3 + bench "eq differ" $ whnf (==u2a) u3, + bench "compare same" $ whnf (compare u2a) u2b, + bench "compare differ" $ whnf (compare u2a) u3 ], bgroup "conversion" [ bench "toString" $ nf U.toString u1, bench "fromString" $ nf U.fromString s1, bench "toByteString" $ nf U.toByteString u1, - bench "fromByteString" $ nf U.fromByteString b1 + bench "fromByteString" $ nf U.fromByteString b1, + bench "toASCIIBytes" $ nf U.toASCIIBytes u1, + bench "fromASCIIBytes" $ nf U.fromASCIIBytes a1, + bench "toWords" $ nf U.toWords u1, + bench "fromWords" $ nf (U.fromWords w1a w1b w1c) w1d, + bench "toText" $ nf U.toText u1, + bench "fromText" $ nf U.fromText t1 ], - bench "set making" $ nf Set.fromList uuids, + + bench "Set making" $ nf Set.fromList uuids, + bench "HashSet making" $ nf HashSet.fromList uuids, bgroup "storable" [ bench "peek" $ nfIO (peek uuidPtr), diff --git a/uuid-types/uuid-types.cabal b/uuid-types/uuid-types.cabal index e9bc34d..32c4bea 100644 --- a/uuid-types/uuid-types.cabal +++ b/uuid-types/uuid-types.cabal @@ -76,4 +76,5 @@ benchmark benchmark containers >= 0.4 && < 0.6, criterion >= 0.4 && < 1.2, deepseq >= 1.1 && < 1.5, - random >= 1.0.1 && < 1.2 + random >= 1.0.1 && < 1.2, + unordered-containers >= 0.2.7 && < 0.3