mirror of
https://github.com/composewell/streamly.git
synced 2024-09-20 16:08:20 +03:00
4810c8eef6
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.
33 lines
910 B
Haskell
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
|
|
]
|
|
]
|