@@ -21,6 +21,7 @@ import qualified Data.Text as T
21import qualified Data.Text.Lazy as LT
21import qualified Data.Text.Lazy as LT
22import qualified Data.Text.Lazy.Builder as LTB
22import qualified Data.Text.Lazy.Builder as LTB
23import qualified Data.Text.Lazy.Builder.Int as Int
23import qualified Data.Text.Lazy.Builder.Int as Int
24+import Data.Int (Int64)
25benchmark :: IO Benchmark
26benchmark :: IO Benchmark
26benchmark = return $ bgroup "Builder"
27benchmark = return $ bgroup "Builder"
@@ -38,17 +39,22 @@ benchmark = return $ bgroup "Builder"
38 [ bgroup "Decimal"
39 [ bgroup "Decimal"
39 [ bgroup "Positive" .
40 [ bgroup "Positive" .
40 flip map numbers $ \n ->
41 flip map numbers $ \n ->
41− (bench (show n) $ nf (LTB.toLazyText . Int.decimal) n)
42+ (bench (show (length (show n))) $ nf (LTB.toLazyText . Int.decimal) n)
42 , bgroup "Negative" .
43 , bgroup "Negative" .
43 flip map numbers $ \m ->
44 flip map numbers $ \m ->
44 let n = negate m in
45 let n = negate m in
45− (bench (show n) $ nf (LTB.toLazyText . Int.decimal) n)
46+ (bench (show (length (show n))) $ nf (LTB.toLazyText . Int.decimal) n)
50− numbers = [6,1,14,93,500,415,9688,2865,10654,30214,795659,829056,6207351,
51+ numbers :: [Int64]
51− 5608880,33929478,96076286,370106126,731223504] :: [Int]
52+ numbers = [
53+ 6, 14, 500, 9688, 10654, 620735, 5608880, 37010612,
54+ 731223504, 5061580596, 24596952933, 711732309084, 2845910093839,
55+ 54601756118340, 735159434806159, 3619097625502435, 95777227510267124,
56+ 414944309510675693, 8986407456998704019
53texts :: [T.Text]
59texts :: [T.Text]
54texts = take 200000 $ cycle ["foo", "λx", "由の"]
60texts = take 200000 $ cycle ["foo", "λx", "由の"]