1-- | UTF-8 encode a text
3-- Tested in this benchmark:
5-- * Replicating a string a number of times
9module Benchmarks.EncodeUtf8
13import Criterion (Benchmark, bgroup, bench, whnf)
14import qualified Data.ByteString as B
15import qualified Data.ByteString.Lazy as BL
16import qualified Data.Text as T
17import qualified Data.Text.Encoding as T
18import qualified Data.Text.Lazy as TL
19import qualified Data.Text.Lazy.Encoding as TL
21benchmark :: String -> IO Benchmark
23 return $ bgroup "EncodeUtf8"
24 [ bench "Text" $ whnf (B.length . T.encodeUtf8) text
25 , bench "LazyText" $ whnf (BL.length . TL.encodeUtf8) lazyText
28 -- The string in different formats
29 text = T.replicate k $ T.pack string
30 lazyText = TL.replicate (fromIntegral k) $ TL.pack string
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list