Skip to content

Instantly share code, notes, and snippets.

@takaki
Created October 28, 2012 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaki/3967886 to your computer and use it in GitHub Desktop.
Save takaki/3967886 to your computer and use it in GitHub Desktop.
blaze-builder sample
import Data.Monoid
import Blaze.ByteString.Builder
import Blaze.ByteString.Builder.Char.Utf8
import qualified Data.ByteString.Char8 as BSC
main = do
let end = 50000
-- print $ foldl1 (++) (map show [1..end]) -- too much slow
print $ length $ BSC.unpack $ toByteString $ foldl1 mappend $ map fromString $ (map show) [1..end]
print $ length $ BSC.unpack $ foldl1 mappend $ map BSC.pack $ Prelude.map show [1..end] -- slow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment