Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

24 lines (18 sloc) 0.744 kb
import Criterion.Main
import Control.Monad
import Control.Monad.Trans.Class
import Control.Pipe
import System.IO
printer :: Show a => Handle -> Pipe a x IO r
printer h = forever $ await >>= lift . hPutStrLn h . show
devnull :: IO Handle
devnull = openFile "/dev/null" WriteMode
main :: IO ()
main = do
h <- devnull
defaultMain
[ bench "list >+> printer (1000)" (whnfIO $ runPipe $ mapM_ yield [1..1000 :: Int] >+> printer h)
, bench "mapM_ print (1000)" (whnfIO $ mapM_ (hPutStrLn h . show) [1..1000 :: Int])
, bench "list >+> printer (100000)" (whnfIO $ runPipe $ mapM_ yield [1..100000 :: Int] >+> printer h)
, bench "mapM_ print (100000)" (whnfIO $ mapM_ (hPutStrLn h . show) [1..100000 :: Int])
]
Jump to Line
Something went wrong with that request. Please try again.