on master help sign in
Compare Show instance performance
8a402c1Bryan O'Sullivan
benchmarks/haskell/Benchmarks/Builder.hs+5−1
@@ -12,7 +12,7 @@ module Benchmarks.Builder
12import Criterion (Benchmark, bgroup, bench, nf)
12import Criterion (Benchmark, bgroup, bench, nf)
13import Data.Binary.Builder as B
13import Data.Binary.Builder as B
14import Data.ByteString.Char8 ()
14import Data.ByteString.Char8 ()
15−import Data.Monoid (mconcat)
15+import Data.Monoid (mconcat, mempty)
16import qualified Blaze.ByteString.Builder as Blaze
16import qualified Blaze.ByteString.Builder as Blaze
17import qualified Blaze.ByteString.Builder.Char.Utf8 as Blaze
17import qualified Blaze.ByteString.Builder.Char.Utf8 as Blaze
18import qualified Data.ByteString as SB
18import qualified Data.ByteString as SB
@@ -44,6 +44,10 @@ benchmark = return $ bgroup "Builder"
44 flip map numbers $ \m ->
44 flip map numbers $ \m ->
45 let n = negate m in
45 let n = negate m in
46 (bench (show (length (show n))) $ nf (LTB.toLazyText . Int.decimal) n)
46 (bench (show (length (show n))) $ nf (LTB.toLazyText . Int.decimal) n)
47+ , bench "Empty" $ nf LTB.toLazyText mempty
48+ , bgroup "Show" .
49+ flip map numbers $ \n ->
50+ (bench (show (length (show n))) $ nf show n)
47 ]
51 ]
48 ]
52 ]
49 ]
53 ]