Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update benchmarks.

Fixed and updated benchmarks to the latest conduit and pipes-extra.

Benchmarks are now integrated in cabal, so you can run them with
something like:

    cabal configure --enable-benchmarks
    cabal build
    cabal bench
  • Loading branch information...
commit 143b53b0ebd30ba98b92a598cb5375d3cd86f783 1 parent d2266fd
@pcapriotti authored
View
31 Benchmarks/general.hs
@@ -1,31 +0,0 @@
-import Criterion.Main
-import qualified Data.Conduit as C
-import qualified Data.Conduit.List as CL
-import qualified Data.Conduit.Binary as CB
-
-import Control.Pipe.Binary
-import Control.Pipe.Combinators
-import Control.Pipe.Conduit
-import Control.Pipe
-
-main :: IO ()
-main = defaultMain
- [ bench "bigsum-pipes" (whnfIO $ runPipe $ (mapM_ yield [1..1000 :: Int] >> return 0) >+> fold (+) 0)
- , bench "bigsum-buffer" (whnfIO $ C.runResourceT $ do
- bsrc <- C.bufferSource $ CL.sourceList [1..1000 :: Int]
- bsrc C.$$ CL.fold (+) 0)
- , bench "fileread-pipes" (whnfIO $ runPipe $ fileReader "general" >+> discard)
- , bench "fileread-adapters" (whnfIO $ C.runResourceT . runPipe $ sourcePipe (CB.sourceFile "general") >+> discard)
- , bench "fileread" (whnfIO $ C.runResourceT $ CB.sourceFile "general" C.$$ CL.sinkNull)
- , bench "fileread-buffer" (whnfIO $ C.runResourceT $ do
- bsrc <- C.bufferSource $ CB.sourceFile "general"
- bsrc C.$$ CL.sinkNull)
- , bench "map-pipes" (whnfIO $ runPipe $ (mapM_ yield [1..1000 :: Int] >> return 0) >+> pipe (+1) >+> fold (+) 0)
- , bench "map" (whnfIO $ C.runResourceT $ CL.sourceList [1..1000 :: Int] C.$= CL.map (+ 1) C.$$ CL.fold (+) 0)
- , bench "map-buffer" (whnfIO $ C.runResourceT $ do
- bsrc <- C.bufferSource $ CL.sourceList [1..1000 :: Int]
- bsrc C.$= CL.map (+ 1) C.$$ CL.fold (+) 0)
- , bench "map-buffer-alt" (whnfIO $ C.runResourceT $ do
- bsrc <- C.bufferSource $ CL.sourceList [1..1000 :: Int] C.$= CL.map (+ 1)
- bsrc C.$$ CL.fold (+) 0)
- ]
View
BIN  Benchmarks/simple
Binary file not shown
View
0  Benchmarks/.gitignore → bench/.gitignore
File renamed without changes
View
21 bench/general.hs
@@ -0,0 +1,21 @@
+import Criterion.Main
+import qualified Data.Conduit as C
+import qualified Data.Conduit.List as CL
+import qualified Data.Conduit.Binary as CB
+
+import Control.Pipe.Binary
+import Control.Pipe.Combinators
+import Control.Pipe
+
+testFile :: FilePath
+testFile = "bench/general.hs"
+
+main :: IO ()
+main = defaultMain
+ [ bench "bigsum-pipes" (whnfIO $ runPipe $ (mapM_ yield [1..1000 :: Int] >> return 0) >+> fold (+) 0)
+ , bench "bigsum-conduit" (whnfIO $ C.runResourceT $ CL.sourceList [1..1000 :: Int] C.$$ CL.fold (+) 0)
+ , bench "fileread-pipes" (whnfIO $ runPipe $ fileReader testFile >+> discard)
+ , bench "fileread-conduit" (whnfIO $ C.runResourceT $ CB.sourceFile testFile C.$$ CL.sinkNull)
+ , bench "map-pipes" (whnfIO $ runPipe $ (mapM_ yield [1..1000 :: Int] >> return 0) >+> pipe (+1) >+> fold (+) 0)
+ , bench "map-conduit" (whnfIO $ C.runResourceT $ CL.sourceList [1..1000 :: Int] C.$= CL.map (+ 1) C.$$ CL.fold (+) 0)
+ ]
View
0  Benchmarks/sample.gz → bench/sample.gz
File renamed without changes
View
1  Benchmarks/simple.hs → bench/simple.hs
@@ -1,6 +1,7 @@
import Criterion.Main
import Control.Monad
+import Control.Monad.Trans.Class
import Control.Pipe
import System.IO
View
15 Benchmarks/zlib.hs → bench/zlib.hs
@@ -15,27 +15,30 @@ import qualified Control.Pipe.Binary as PB
import qualified Control.Pipe.Zlib as PZ
filePath :: FilePath
-filePath = "sample.gz"
+filePath = "bench/sample.gz"
+
+tmpFile :: FilePath
+tmpFile = "dist/build/autogen/bench-tmp"
lazyIO :: IO ()
lazyIO = do
compressed <- L.readFile filePath
- L.writeFile "tmp" $ GZip.decompress compressed
+ L.writeFile tmpFile $ GZip.decompress compressed
conduits1 :: IO ()
conduits1 = C.runResourceT
$ CB.sourceFile filePath
C.$$ CZ.ungzip
- C.=$ CB.sinkFile "tmp"
+ C.=$ CB.sinkFile tmpFile
conduits2 :: IO ()
conduits2 = C.runResourceT
$ CB.sourceFile filePath
C.$= CZ.ungzip
- C.$$ CB.sinkFile "tmp"
+ C.$$ CB.sinkFile tmpFile
enumerator :: IO ()
-enumerator = SIO.withBinaryFile "tmp" SIO.WriteMode $ \h -> E.run_
+enumerator = SIO.withBinaryFile tmpFile SIO.WriteMode $ \h -> E.run_
$ EB.enumFile filePath
E.$$ EZ.ungzip
E.=$ EB.iterHandle h
@@ -44,7 +47,7 @@ pipes :: IO ()
pipes = runPipe
$ PB.fileReader filePath
>+> PZ.gunzip
- >+> PB.fileWriter "tmp"
+ >+> PB.fileWriter tmpFile
main :: IO ()
main = defaultMain
View
36 pipes-extra.cabal
@@ -28,3 +28,39 @@ Library
Control.Pipe.PutbackPipe,
Control.Pipe.Tee,
Control.Pipe.Zip
+
+benchmark bench-general
+ type: exitcode-stdio-1.0
+ hs-source-dirs: . bench
+ main-is: general.hs
+ build-depends: base == 4.*
+ , pipes-core == 0.1.*
+ , bytestring == 0.9.*
+ , transformers >= 0.2 && < 0.4
+ , conduit == 0.4.*
+ , criterion == 0.6.*
+
+benchmark bench-simple
+ type: exitcode-stdio-1.0
+ hs-source-dirs: . bench
+ main-is: simple.hs
+ build-depends: base == 4.*
+ , pipes-core == 0.1.*
+ , transformers >= 0.2 && < 0.4
+ , criterion == 0.6.*
+
+benchmark bench-zlib
+ type: exitcode-stdio-1.0
+ hs-source-dirs: . bench
+ main-is: zlib.hs
+ build-depends: base == 4.*
+ , pipes-core == 0.1.*
+ , pipes-zlib < 0.2
+ , bytestring == 0.9.*
+ , transformers >= 0.2 && < 0.4
+ , enumerator == 0.4.*
+ , zlib-enum == 0.2.*
+ , conduit == 0.4.*
+ , zlib-conduit == 0.4.*
+ , zlib == 0.5.*
+ , criterion == 0.6.*
Please sign in to comment.
Something went wrong with that request. Please try again.