Commit bdb64830 authored by Alex Biehl's avatar Alex Biehl Committed by Xia Li-yao
Browse files

Benchmark encodeUtf8Builder

parent 8baf7a16
......@@ -10,8 +10,10 @@ module Benchmarks.EncodeUtf8
( benchmark
) where
import Test.Tasty.Bench (Benchmark, bgroup, bench, whnf)
import Test.Tasty.Bench (Benchmark, bgroup, bench, nf, whnf)
import qualified Data.ByteString as B
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Builder.Prim as BP
import qualified Data.ByteString.Lazy as BL
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
......@@ -23,6 +25,8 @@ benchmark name string =
bgroup name
[ bench "Text" $ whnf (B.length . T.encodeUtf8) text
, bench "LazyText" $ whnf (BL.length . TL.encodeUtf8) lazyText
, bench "Text/encodeUtf8Builder" $ nf (B.toLazyByteString . T.encodeUtf8Builder) text
, bench "Text/encodeUtf8BuilderEscaped" $ nf (B.toLazyByteString . T.encodeUtf8BuilderEscaped (BP.liftFixedToBounded BP.word8)) text
-- The string in different formats
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment