@@ -4,7 +4,7 @@
5-- * Most pure functions defined the string types
5-- * Most pure functions defined the string types
7−{-# LANGUAGE BangPatterns, GADTs, MagicHash #-}
7+{-# LANGUAGE BangPatterns, CPP, GADTs, MagicHash #-}
8{-# OPTIONS_GHC -fno-warn-orphans #-}
8{-# OPTIONS_GHC -fno-warn-orphans #-}
9module Benchmarks.Pure
9module Benchmarks.Pure
10 ( benchmark
10 ( benchmark
@@ -27,8 +27,8 @@ import qualified Data.Text.Lazy as TL
27import qualified Data.Text.Lazy.Builder as TB
27import qualified Data.Text.Lazy.Builder as TB
28import qualified Data.Text.Lazy.Encoding as TL
28import qualified Data.Text.Lazy.Encoding as TL
30−benchmark :: FilePath -> IO Benchmark
30+benchmark :: String -> FilePath -> IO Benchmark
31−benchmark fp = do
31+benchmark kind fp = do
32 -- Evaluate stuff before actually running the benchmark, we don't want to
32 -- Evaluate stuff before actually running the benchmark, we don't want to
33 -- count it here.
33 -- count it here.
@@ -100,6 +100,10 @@ benchmark fp = do
100 , benchBSL $ nf BL.unpack bla
100 , benchBSL $ nf BL.unpack bla
101 , benchS $ nf UTF8.toString bsa
101 , benchS $ nf UTF8.toString bsa
104+ [ benchT $ nf T.decodeUtf8' bsa
105+ , benchTL $ nf TL.decodeUtf8' bla
103 , bgroup "drop"
107 , bgroup "drop"
104 [ benchT $ nf (T.drop (ta_len `div` 3)) ta
108 [ benchT $ nf (T.drop (ta_len `div` 3)) ta
105 , benchTL $ nf (TL.drop (tla_len `div` 3)) tla
109 , benchTL $ nf (TL.drop (tla_len `div` 3)) tla
@@ -405,11 +409,11 @@ benchmark fp = do
408− benchS = bench "String"
412+ benchS = bench ("String+" ++ kind)
409− benchT = bench "Text"
413+ benchT = bench ("Text+" ++ kind)
410− benchTL = bench "LazyText"
414+ benchTL = bench ("LazyText+" ++ kind)
411− benchBS = bench "ByteString"
415+ benchBS = bench ("ByteString+" ++ kind)
412− benchBSL = bench "LazyByteString"
416+ benchBSL = bench ("LazyByteString+" ++ kind)
415 p0 = (== c)
419 p0 = (== c)
@@ -425,11 +429,13 @@ benchmark fp = do
425 replicat n = concat . L.replicate n
429 replicat n = concat . L.replicate n
426 short = T.pack "short"
430 short = T.pack "short"
432+#if !MIN_VERSION_bytestring(0,10,0)
428instance NFData BS.ByteString
433instance NFData BS.ByteString
430instance NFData BL.ByteString where
435instance NFData BL.ByteString where
431 rnf BL.Empty = ()
436 rnf BL.Empty = ()
432 rnf (BL.Chunk _ ts) = rnf ts
437 rnf (BL.Chunk _ ts) = rnf ts
434data B where
440data B where
435 B :: NFData a => a -> B
441 B :: NFData a => a -> B