streamly/benchmark/NestedUnfold.hs
Harendra Kumar 4810c8eef6 Add nested unfold operations and benchmarks
Especially add chaining of unfolds and outerProduct operations. outerProduct is
just the cartesian product of two streams, it is like the concatMap/bind for
streams. In contrast to concatMap, the unfold nested looping operations are
amenable to complete fusion providing us amazing performance equivalent to
linear stream operations.
2019-09-29 01:37:22 +05:30

33 lines
910 B
Haskell

-- |
-- Module : NestedUnfold
-- Copyright : (c) 2019 Composewell Technologies
--
-- License : BSD3
-- Maintainer : streamly@composewell.com
import Control.DeepSeq (NFData)
import System.Random (randomRIO)
import qualified NestedUnfoldOps as Ops
import Gauge
benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
main :: IO ()
main =
defaultMain
[ bgroup "unfold"
[ benchIO "toNull" $ Ops.toNull
, benchIO "toNull3" $ Ops.toNull3
, benchIO "concat" $ Ops.concat
, benchIO "toList" $ Ops.toList
, benchIO "toListSome" $ Ops.toListSome
, benchIO "filterAllOut" $ Ops.filterAllOut
, benchIO "filterAllIn" $ Ops.filterAllIn
, benchIO "filterSome" $ Ops.filterSome
, benchIO "breakAfterSome" $ Ops.breakAfterSome
]
]