on master help sign in
Benchmark encoding
0463c40Bryan O'Sullivan
tests/Benchmarks.hs+8−1
@@ -8,7 +8,7 @@ import Control.Exception (evaluate)
8import Criterion.Main
8import Criterion.Main
9import Data.Char
9import Data.Char
10import Data.Monoid (mappend, mempty)
10import Data.Monoid (mappend, mempty)
11−import qualified Codec.Binary.UTF8.Generic as UTF8
11+import qualified Data.ByteString.UTF8 as UTF8
12import qualified Data.Text as TS
12import qualified Data.Text as TS
13import qualified Data.Text.IO as TS
13import qualified Data.Text.IO as TS
14import qualified Data.Text.Lazy as TL
14import qualified Data.Text.Lazy as TL
@@ -114,6 +114,13 @@ main = do
114 , bench "bl" $ nf (BL.drop (bla_len `div` 3)) bla
114 , bench "bl" $ nf (BL.drop (bla_len `div` 3)) bla
115 , bench "l" $ nf (L.drop (la_len `div` 3)) la
115 , bench "l" $ nf (L.drop (la_len `div` 3)) la
116 ],
116 ],
117+ bgroup "encode" [
118+ bench "ts" $ nf TS.encodeUtf8 tsa
119+ , bench "tl" $ nf TL.encodeUtf8 tla
120+ , bench "bs" $ nf BS.pack la
121+ , bench "bl" $ nf BL.pack la
122+ , bench "l" $ nf UTF8.fromString la
123+ ],
117 bgroup "filter" [
124 bgroup "filter" [
118 bench "ts" $ nf (TS.filter p0) tsa
125 bench "ts" $ nf (TS.filter p0) tsa
119 , bench "tl" $ nf (TL.filter p0) tla
126 , bench "tl" $ nf (TL.filter p0) tla