1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Criterion.Main
import qualified Data.Text as T
import Text.Wrap
smallDocument :: T.Text
smallDocument =
T.unlines $
replicate 10 $
T.concat $
replicate 1000 "foobar stuff things x "
mediumDocument :: T.Text
mediumDocument =
T.unlines $
replicate 100 $
T.concat $
replicate 1000 "foobar stuff things x "
largeDocument :: T.Text
largeDocument =
T.unlines $
replicate 1000 $
T.concat $
replicate 1000 "foobar stuff things x "
breakSettings :: WrapSettings
breakSettings = defaultWrapSettings { breakLongWords = True }
cases :: [Benchmark]
cases =
[ bench "small_default" $ nf (wrapTextToLines defaultWrapSettings 10) smallDocument
, bench "medium_default" $ nf (wrapTextToLines defaultWrapSettings 10) mediumDocument
, bench "large_deafult" $ nf (wrapTextToLines defaultWrapSettings 10) largeDocument
, bench "small_break" $ nf (wrapTextToLines breakSettings 5) smallDocument
, bench "medium_break" $ nf (wrapTextToLines breakSettings 5) mediumDocument
, bench "large_break" $ nf (wrapTextToLines breakSettings 5) largeDocument
]
main :: IO ()
main = defaultMain cases
|