2-- Module : BenchmarkOps
3-- Copyright : (c) 2018 Harendra Kumar
6-- Maintainer : streamly@composewell.com
8{-# LANGUAGE FlexibleContexts #-}
9{-# LANGUAGE ScopedTypeVariables #-}
13import Control.Exception (try)
14import GHC.Exception (ErrorCall)
16import qualified Streamly as S hiding (runStream)
17import qualified Streamly.Prelude as S
24-- nestedCount2 = round (fromIntegral linearCount**(1/2::Double))
29nestedCount3 = round (fromIntegral linearCount**(1/3::Double))
31-------------------------------------------------------------------------------
32-- Stream generation and elimination
33-------------------------------------------------------------------------------
35type Stream m a = S.SerialT m a
38source :: (S.MonadAsync m, S.IsStream t) => Int -> Int -> t m Int
39source = sourceUnfoldrM
41{-# INLINE sourceUnfoldrM #-}
42sourceUnfoldrM :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m Int
43sourceUnfoldrM n value = S.serially $ S.unfoldrM step n
48 else return (Just (cnt, cnt + 1))
50{-# INLINE sourceUnfoldr #-}
51sourceUnfoldr :: (Monad m, S.IsStream t) => Int -> Int -> t m Int
52sourceUnfoldr start n = S.unfoldr step start
57 else Just (cnt, cnt + 1)
59{-# INLINE runStream #-}
60runStream :: Monad m => Stream m a -> m ()
63{-# INLINE runToList #-}
64runToList :: Monad m => Stream m a -> m [a]
67-------------------------------------------------------------------------------
69-------------------------------------------------------------------------------
71{-# INLINE toNullAp #-}
73 :: (S.IsStream t, S.MonadAsync m, Applicative (t m))
74 => (t m Int -> S.SerialT m Int) -> Int -> m ()
75toNullAp t start = runStream . t $
76 (+) <$> source start nestedCount2 <*> source start nestedCount2
80 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
81 => (t m Int -> S.SerialT m Int) -> Int -> m ()
82toNull t start = runStream . t $ do
83 x <- source start nestedCount2
84 y <- source start nestedCount2
89 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
90 => (t m Int -> S.SerialT m Int) -> Int -> m ()
91toNull3 t start = runStream . t $ do
92 x <- source start nestedCount3
93 y <- source start nestedCount3
94 z <- source start nestedCount3
99 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
100 => (t m Int -> S.SerialT m Int) -> Int -> m [Int]
101toList t start = runToList . t $ do
102 x <- source start nestedCount2
103 y <- source start nestedCount2
106{-# INLINE toListSome #-}
108 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
109 => (t m Int -> S.SerialT m Int) -> Int -> m [Int]
111 runToList . t $ S.take 1000 $ do
112 x <- source start nestedCount2
113 y <- source start nestedCount2
116{-# INLINE filterAllOut #-}
118 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
119 => (t m Int -> S.SerialT m Int) -> Int -> m ()
120filterAllOut t start = runStream . t $ do
121 x <- source start nestedCount2
122 y <- source start nestedCount2
128{-# INLINE filterAllIn #-}
130 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
131 => (t m Int -> S.SerialT m Int) -> Int -> m ()
132filterAllIn t start = runStream . t $ do
133 x <- source start nestedCount2
134 y <- source start nestedCount2
140{-# INLINE filterSome #-}
142 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
143 => (t m Int -> S.SerialT m Int) -> Int -> m ()
144filterSome t start = runStream . t $ do
145 x <- source start nestedCount2
146 y <- source start nestedCount2
152{-# INLINE breakAfterSome #-}
154 :: (S.IsStream t, Monad (t IO))
155 => (t IO Int -> S.SerialT IO Int) -> Int -> IO ()
156breakAfterSome t start = do
157 (_ :: Either ErrorCall ()) <- try $ runStream . t $ do
158 x <- source start nestedCount2
159 y <- source start nestedCount2
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list