@@ -8,6 +8,7 @@ import qualified Data.ByteString.Lazy.Internal as BL
8import Criterion.Main
8import Criterion.Main
9import Data.Maybe (fromJust)
9import Data.Maybe (fromJust)
10import qualified Data.Set as Set
10import qualified Data.Set as Set
11+import qualified Data.HashSet as HashSet
11import qualified Data.ByteString.Lazy as BL
12import qualified Data.ByteString.Lazy as BL
12import qualified Data.UUID.Types as U
13import qualified Data.UUID.Types as U
13import Foreign (alloca, peek, poke)
14import Foreign (alloca, peek, poke)
@@ -24,6 +25,9 @@ main = do
24 u1 <- randomIO
25 u1 <- randomIO
25 let s1 = U.toString u1
26 let s1 = U.toString u1
26 b1 = U.toByteString u1
27 b1 = U.toByteString u1
28+ a1 = U.toASCIIBytes u1
30+ (w1a,w1b,w1c,w1d) = U.toWords u1
27 nil2 = fromJust $
31 nil2 = fromJust $
28 U.fromString "00000000-0000-0000-0000-000000000000"
32 U.fromString "00000000-0000-0000-0000-000000000000"
29 u2a = fromJust $ U.fromString "169a5a43-c051-4a16-98f4-08447ddd5dc0"
33 u2a = fromJust $ U.fromString "169a5a43-c051-4a16-98f4-08447ddd5dc0"
@@ -43,15 +47,25 @@ main = do
43 bench "null nil" $ whnf U.null U.nil,
47 bench "null nil" $ whnf U.null U.nil,
44 bench "null nil2" $ whnf U.null nil2,
48 bench "null nil2" $ whnf U.null nil2,
45 bench "eq same" $ whnf (==u2a) u2b,
49 bench "eq same" $ whnf (==u2a) u2b,
46− bench "eq differ" $ whnf (==u2a) u3
50+ bench "eq differ" $ whnf (==u2a) u3,
51+ bench "compare same" $ whnf (compare u2a) u2b,
52+ bench "compare differ" $ whnf (compare u2a) u3
48 bgroup "conversion" [
54 bgroup "conversion" [
49 bench "toString" $ nf U.toString u1,
55 bench "toString" $ nf U.toString u1,
50 bench "fromString" $ nf U.fromString s1,
56 bench "fromString" $ nf U.fromString s1,
51 bench "toByteString" $ nf U.toByteString u1,
57 bench "toByteString" $ nf U.toByteString u1,
52− bench "fromByteString" $ nf U.fromByteString b1
58+ bench "fromByteString" $ nf U.fromByteString b1,
59+ bench "toASCIIBytes" $ nf U.toASCIIBytes u1,
60+ bench "fromASCIIBytes" $ nf U.fromASCIIBytes a1,
61+ bench "toWords" $ nf U.toWords u1,
62+ bench "fromWords" $ nf (U.fromWords w1a w1b w1c) w1d,
63+ bench "toText" $ nf U.toText u1,
64+ bench "fromText" $ nf U.fromText t1
54− bench "set making" $ nf Set.fromList uuids,
67+ bench "Set making" $ nf Set.fromList uuids,
68+ bench "HashSet making" $ nf HashSet.fromList uuids,
56 bgroup "storable" [
70 bgroup "storable" [
57 bench "peek" $ nfIO (peek uuidPtr),
71 bench "peek" $ nfIO (peek uuidPtr),