Commits

Bryan O'Sullivan  committed 4735dcf Merge

Merge with Jasper

  • Participants
  • Parent commits c92ee73, cfb243c

Comments (0)

Files changed (1)

File tests/benchmarks/src/Data/Text/Benchmarks/Equality.hs

 benchmark :: FilePath -> IO Benchmark
 benchmark fp = do
   b <- B.readFile fp
-  bl <- BL.readFile fp
+  bl1 <- BL.readFile fp
+  -- A lazy bytestring is a list of chunks. When we do not explicitly create two
+  -- different lazy bytestrings at a different address, the bytestring library
+  -- will compare the chunk addresses instead of the chunk contents. This is why
+  -- we read the lazy bytestring twice here.
+  bl2 <- BL.readFile fp
   l <- readFile fp
   let t  = T.decodeUtf8 b
-      tl = TL.decodeUtf8 bl
+      tl = TL.decodeUtf8 bl1
   return $ bgroup "Equality"
     [ bench "Text" $ whnf (== T.init t `T.snoc` '\xfffd') t
     , bench "LazyText" $ whnf (== TL.init tl `TL.snoc` '\xfffd') tl
     , bench "ByteString" $ whnf (== B.init b `B.snoc` '\xfffd') b
-    , bench "LazyByteString" $ whnf (== BL.init bl `BL.snoc` '\xfffd') bl
+    , bench "LazyByteString" $ whnf (== BL.init bl2 `BL.snoc` '\xfffd') bl1
     , bench "String" $ whnf (== init l ++ "\xfffd") l
     ]