on master help sign in
Merge with Jasper
bcec392Bryan O'Sullivan
tests/benchmarks/src/Data/Text/Benchmarks/Equality.hs+8−3
@@ -17,14 +17,19 @@ import qualified Data.Text.Lazy.Encoding as TL
17benchmark :: FilePath -> IO Benchmark
17benchmark :: FilePath -> IO Benchmark
18benchmark fp = do
18benchmark fp = do
19 b <- B.readFile fp
19 b <- B.readFile fp
20+ bl1 <- BL.readFile fp
21+ -- A lazy bytestring is a list of chunks. When we do not explicitly create two
22+ -- different lazy bytestrings at a different address, the bytestring library
23+ -- will compare the chunk addresses instead of the chunk contents. This is why
24+ -- we read the lazy bytestring twice here.
20− bl <- BL.readFile fp
25+ bl2 <- BL.readFile fp
21 l <- readFile fp
26 l <- readFile fp
22 let t = T.decodeUtf8 b
27 let t = T.decodeUtf8 b
23− tl = TL.decodeUtf8 bl
28+ tl = TL.decodeUtf8 bl1
24 return $ bgroup "Equality"
29 return $ bgroup "Equality"
25 [ bench "Text" $ whnf (== T.init t `T.snoc` '\xfffd') t
30 [ bench "Text" $ whnf (== T.init t `T.snoc` '\xfffd') t
26 , bench "LazyText" $ whnf (== TL.init tl `TL.snoc` '\xfffd') tl
31 , bench "LazyText" $ whnf (== TL.init tl `TL.snoc` '\xfffd') tl
27 , bench "ByteString" $ whnf (== B.init b `B.snoc` '\xfffd') b
32 , bench "ByteString" $ whnf (== B.init b `B.snoc` '\xfffd') b
28− , bench "LazyByteString" $ whnf (== BL.init bl `BL.snoc` '\xfffd') bl
33+ , bench "LazyByteString" $ whnf (== BL.init bl2 `BL.snoc` '\xfffd') bl1
29 , bench "String" $ whnf (== init l ++ "\xfffd") l
34 , bench "String" $ whnf (== init l ++ "\xfffd") l
30 ]
35 ]