Skip to content

Instantly share code, notes, and snippets.

@Dema
Created December 19, 2012 17:02
Show Gist options
  • Save Dema/4338324 to your computer and use it in GitHub Desktop.
Save Dema/4338324 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Criterion.Main
import Criterion.Config
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Lazy.Char8 as C
import GHC.Word
bstring = B.unpack . C.pack
map_:: String -> [GHC.Word.Word8]
map_ = map (fromIntegral.fromEnum)
dataZ = take 100000 $ repeat 'a'
main = defaultMainWith defaultConfig (return ()) [
bgroup "tiny" [ bench "bytestring" $ whnf bstring dataZ
, bench "map" $ whnf map_ dataZ
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment