Skip to content

Commit bdb6483

Browse files
alexbiehlLysxia
authored andcommitted
Benchmark encodeUtf8Builder
1 parent 8baf7a1 commit bdb6483

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

benchmarks/haskell/Benchmarks/EncodeUtf8.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ module Benchmarks.EncodeUtf8
1010
( benchmark
1111
) where
1212

13-
import Test.Tasty.Bench (Benchmark, bgroup, bench, whnf)
13+
import Test.Tasty.Bench (Benchmark, bgroup, bench, nf, whnf)
1414
import qualified Data.ByteString as B
15+
import qualified Data.ByteString.Builder as B
16+
import qualified Data.ByteString.Builder.Prim as BP
1517
import qualified Data.ByteString.Lazy as BL
1618
import qualified Data.Text as T
1719
import qualified Data.Text.Encoding as T
@@ -23,6 +25,8 @@ benchmark name string =
2325
bgroup name
2426
[ bench "Text" $ whnf (B.length . T.encodeUtf8) text
2527
, bench "LazyText" $ whnf (BL.length . TL.encodeUtf8) lazyText
28+
, bench "Text/encodeUtf8Builder" $ nf (B.toLazyByteString . T.encodeUtf8Builder) text
29+
, bench "Text/encodeUtf8BuilderEscaped" $ nf (B.toLazyByteString . T.encodeUtf8BuilderEscaped (BP.liftFixedToBounded BP.word8)) text
2630
]
2731
where
2832
-- The string in different formats

0 commit comments

Comments
 (0)