Commits

Bryan O'Sullivan committed 5f3ff81

Bump dependency on criterion to 0.10

Comments (0)

Files changed (12)

benchmarks/haskell/Benchmarks/DecodeUtf8.hs

 import Foreign.ForeignPtr (withForeignPtr)
 import Data.Word (Word8)
 import qualified Criterion as C
-import Criterion (Benchmark, bgroup, nf)
+import Criterion (Benchmark, bgroup, nf, whnfIO)
 import qualified Codec.Binary.UTF8.Generic as U8
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as BL
     return $ bgroup "DecodeUtf8"
         [ bench "Strict" $ nf T.decodeUtf8 bs
         , bench "Stream" $ nf decodeStream lbs
-        , bench "IConv" $ iconv bs
+        , bench "IConv" $ whnfIO $ iconv bs
         , bench "StrictLength" $ nf (T.length . T.decodeUtf8) bs
         , bench "StrictInitLength" $ nf (T.length . T.init . T.decodeUtf8) bs
         , bench "Lazy" $ nf TL.decodeUtf8 lbs

benchmarks/haskell/Benchmarks/FileRead.hs

     ( benchmark
     ) where
 
-import Control.Exception (evaluate)
-import Criterion (Benchmark, bgroup, bench)
+import Control.Applicative ((<$>))
+import Criterion (Benchmark, bgroup, bench, whnfIO)
 import qualified Data.ByteString as SB
 import qualified Data.ByteString.Lazy as LB
 import qualified Data.Text as T
 
 benchmark :: FilePath -> IO Benchmark
 benchmark p = return $ bgroup "FileRead"
-    [ bench "String" $ readFile p >>= evaluate . length
-    , bench "ByteString" $ SB.readFile p >>= evaluate . SB.length
-    , bench "LazyByteString" $ LB.readFile p >>= evaluate . LB.length
-    , bench "Text" $ T.readFile p >>= evaluate . T.length
-    , bench "LazyText" $ LT.readFile p >>= evaluate . LT.length
-    , bench "TextByteString" $
-        SB.readFile p >>= evaluate . T.length . T.decodeUtf8
-    , bench "LazyTextByteString" $
-        LB.readFile p >>= evaluate . LT.length . LT.decodeUtf8
+    [ bench "String" $ whnfIO $ length <$> readFile p
+    , bench "ByteString" $ whnfIO $ SB.length <$> SB.readFile p
+    , bench "LazyByteString" $ whnfIO $ LB.length <$> LB.readFile p
+    , bench "Text" $ whnfIO $ T.length <$> T.readFile p
+    , bench "LazyText" $ whnfIO $ LT.length <$> LT.readFile p
+    , bench "TextByteString" $ whnfIO $
+        (T.length . T.decodeUtf8) <$> SB.readFile p
+    , bench "LazyTextByteString" $ whnfIO $
+        (LT.length . LT.decodeUtf8) <$> LB.readFile p
     ]

benchmarks/haskell/Benchmarks/FoldLines.hs

     ( benchmark
     ) where
 
-import Criterion (Benchmark, bgroup, bench)
+import Criterion (Benchmark, bgroup, bench, whnfIO)
 import System.IO
 import qualified Data.ByteString as B
 import qualified Data.Text as T
     , bench "ByteString" $ withHandle $ foldLinesB (\n _ -> n + 1) (0 :: Int)
     ]
   where
-    withHandle f = do
+    withHandle f = whnfIO $ do
         h <- openFile fp ReadMode
         hSetBuffering h (BlockBuffering (Just 16384))
         x <- f h

benchmarks/haskell/Benchmarks/Programs/BigTable.hs

     ( benchmark
     ) where
 
-import Criterion (Benchmark, bench)
+import Criterion (Benchmark, bench, whnfIO)
 import Data.Monoid (mappend, mconcat)
 import Data.Text.Lazy.Builder (Builder, fromText, toLazyText)
 import Data.Text.Lazy.IO (hPutStr)
 import qualified Data.Text as T
 
 benchmark :: Handle -> IO Benchmark
-benchmark sink = return $ bench "BigTable" $ do
+benchmark sink = return $ bench "BigTable" $ whnfIO $ do
     hPutStr sink "Content-Type: text/html\n\n<table>"
     hPutStr sink . toLazyText . makeTable =<< rows
     hPutStr sink "</table>"

benchmarks/haskell/Benchmarks/Programs/Cut.hs

     ( benchmark
     ) where
 
-import Criterion (Benchmark, bgroup, bench)
+import Criterion (Benchmark, bgroup, bench, whnfIO)
 import System.IO (Handle, hPutStr)
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Char8 as BC
     , bench' "LazyTextByteString" lazyTextByteString
     ]
   where
-    bench' n s = bench n (s p sink from to)
+    bench' n s = bench n $ whnfIO (s p sink from to)
 
 string :: FilePath -> Handle -> Int -> Int -> IO ()
 string fp sink from to = do

benchmarks/haskell/Benchmarks/Programs/Fold.hs

 import Data.List (intersperse)
 import Data.Monoid (mempty, mappend, mconcat)
 import System.IO (Handle)
-import Criterion (Benchmark, bench)
+import Criterion (Benchmark, bench, whnfIO)
 import qualified Data.Text as T
 import qualified Data.Text.IO as T
 import qualified Data.Text.Lazy.Builder as TLB
 
 benchmark :: FilePath -> Handle -> IO Benchmark
 benchmark i o = return $
-    bench "Fold" $ T.readFile i >>= TL.hPutStr o . fold 80
+    bench "Fold" $ whnfIO $ T.readFile i >>= TL.hPutStr o . fold 80
 
 -- | We represent a paragraph by a word list
 --

benchmarks/haskell/Benchmarks/Programs/Sort.hs

     ( benchmark
     ) where
 
-import Criterion (Benchmark, bgroup, bench)
+import Criterion (Benchmark, bgroup, bench, whnfIO)
 import Data.Monoid (mconcat)
 import System.IO (Handle, hPutStr)
 import qualified Data.ByteString as B
 
 benchmark :: FilePath -> Handle -> IO Benchmark
 benchmark i o = return $ bgroup "Sort"
-    [ bench "String" $ readFile i >>= hPutStr o . string
-    , bench "ByteString" $ B.readFile i >>= B.hPutStr o . byteString
-    , bench "LazyByteString" $ BL.readFile i >>= BL.hPutStr o . lazyByteString
-    , bench "Text" $ T.readFile i >>= T.hPutStr o . text
-    , bench "LazyText" $ TL.readFile i >>= TL.hPutStr o . lazyText
-    , bench "TextByteString" $ B.readFile i >>=
+    [ bench "String" $ whnfIO $ readFile i >>= hPutStr o . string
+    , bench "ByteString" $ whnfIO $ B.readFile i >>= B.hPutStr o . byteString
+    , bench "LazyByteString" $ whnfIO $
+      BL.readFile i >>= BL.hPutStr o . lazyByteString
+    , bench "Text" $ whnfIO $ T.readFile i >>= T.hPutStr o . text
+    , bench "LazyText" $ whnfIO $ TL.readFile i >>= TL.hPutStr o . lazyText
+    , bench "TextByteString" $ whnfIO $ B.readFile i >>=
         B.hPutStr o . T.encodeUtf8 . text . T.decodeUtf8
-    , bench "LazyTextByteString" $ BL.readFile i >>=
+    , bench "LazyTextByteString" $ whnfIO $ BL.readFile i >>=
         BL.hPutStr o . TL.encodeUtf8 . lazyText .  TL.decodeUtf8
-    , bench "TextBuilder" $ B.readFile i >>=
+    , bench "TextBuilder" $ whnfIO $ B.readFile i >>=
         BL.hPutStr o . TL.encodeUtf8 . textBuilder . T.decodeUtf8
     ]
 

benchmarks/haskell/Benchmarks/Programs/StripTags.hs

     ( benchmark
     ) where
 
-import Criterion (Benchmark, bgroup, bench)
+import Criterion (Benchmark, bgroup, bench, whnfIO)
 import Data.List (mapAccumL)
 import System.IO (Handle, hPutStr)
 import qualified Data.ByteString as B
 
 benchmark :: FilePath -> Handle -> IO Benchmark
 benchmark i o = return $ bgroup "StripTags"
-    [ bench "String" $ readFile i >>= hPutStr o . string
-    , bench "ByteString" $ B.readFile i >>= B.hPutStr o . byteString
-    , bench "Text" $ T.readFile i >>= T.hPutStr o . text
-    , bench "TextByteString" $
+    [ bench "String" $ whnfIO $ readFile i >>= hPutStr o . string
+    , bench "ByteString" $ whnfIO $ B.readFile i >>= B.hPutStr o . byteString
+    , bench "Text" $ whnfIO $ T.readFile i >>= T.hPutStr o . text
+    , bench "TextByteString" $ whnfIO $
         B.readFile i >>= B.hPutStr o . T.encodeUtf8 . text . T.decodeUtf8
     ]
 

benchmarks/haskell/Benchmarks/Programs/Throughput.hs

     ( benchmark
     ) where
 
-import Criterion (Benchmark, bgroup, bench)
+import Criterion (Benchmark, bgroup, bench, whnfIO)
 import System.IO (Handle, hPutStr)
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as BL
 
 benchmark :: FilePath -> Handle -> IO Benchmark
 benchmark fp sink = return $ bgroup "Throughput"
-    [ bench "String" $ readFile fp >>= hPutStr sink
-    , bench "ByteString" $ B.readFile fp >>= B.hPutStr sink
-    , bench "LazyByteString" $ BL.readFile fp >>= BL.hPutStr sink
-    , bench "Text" $ T.readFile fp >>= T.hPutStr sink
-    , bench "LazyText" $ TL.readFile fp >>= TL.hPutStr sink
-    , bench "TextByteString" $
+    [ bench "String" $ whnfIO $ readFile fp >>= hPutStr sink
+    , bench "ByteString" $ whnfIO $ B.readFile fp >>= B.hPutStr sink
+    , bench "LazyByteString" $ whnfIO $ BL.readFile fp >>= BL.hPutStr sink
+    , bench "Text" $ whnfIO $ T.readFile fp >>= T.hPutStr sink
+    , bench "LazyText" $ whnfIO $ TL.readFile fp >>= TL.hPutStr sink
+    , bench "TextByteString" $ whnfIO $
         B.readFile fp >>= B.hPutStr sink . T.encodeUtf8 .  T.decodeUtf8
-    , bench "LazyTextByteString" $
+    , bench "LazyTextByteString" $ whnfIO $
         BL.readFile fp >>= BL.hPutStr sink . TL.encodeUtf8 . TL.decodeUtf8
     ]

benchmarks/text-benchmarks.cabal

                   bytestring,
                   bytestring-lexing,
                   containers,
-                  criterion >= 0.6.0.1,
+                  criterion >= 0.10.0.0,
                   deepseq,
                   directory,
                   filepath,
+1.2.0.0
+
+* Added an instance of IsList for GHC 7.8 and above
+
 1.1.1.0
 
 * The Data.Data instance now allows gunfold to work, via a virtual
 name:           text
-version:        1.1.1.3
+version:        1.2.0.0
 homepage:       https://github.com/bos/text
 bug-reports:    https://github.com/bos/text/issues
 synopsis:       An efficient packed Unicode text type.