on master help sign in
Add list-t to benchmarks
commit6935930caeef5d26437fafde862869344cd69a96 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 10 Aug 2017, 15:25 (9 years ago) parentf4cce2f
2 files changed+27−2
asyncly.cabal+1 benchmark/Main.hs+26−2
asyncly.cabal+1
@@ -77,6 +77,7 @@ benchmark bench
7777 , conduit-combinators
7878 , criterion
7979 , io-streams
80+ , list-t
8081 , machines
8182 , mtl
8283 , pipes
benchmark/Main.hs+26−2
@@ -26,12 +26,14 @@ import qualified Transient.Internals as T
2626import qualified Transient.Indeterminism as T
2727
2828import qualified Data.Machine as M
29+import qualified ListT as LT
2930import qualified Asyncly as A
3031
3132main :: IO ()
3233main = do
3334 defaultMain [
3435 bgroup "basic" [ bench "asyncly" $ nfIO asyncly_basic
36+ , bench "list-t" $ nfIO list_t_basic
3537 , bench "transient" $ nfIO transient_basic
3638 , bench "machines" $ nfIO machines_basic
3739 , bench "stream" $ nfIO stream_basic
@@ -87,10 +89,10 @@ transient_basic = T.keep' $ T.threads 0 $ do
8789 assert (Prelude.length xs == 499000) $
8890 T.exit (Prelude.length xs)
8991
90−amap :: (a -> Int) -> a -> A.AsynclyT IO Int
92+amap :: (Int -> Int) -> Int -> A.AsynclyT IO Int
9193amap = Main.map
9294
93−afilter :: (a -> Bool) -> a -> A.AsynclyT IO a
95+afilter :: (Int -> Bool) -> Int -> A.AsynclyT IO Int
9496afilter = Main.filter
9597
9698adrop :: Int -> Int -> A.AsynclyT IO Int
@@ -109,6 +111,28 @@ asyncly_basic = do
109111 assert (Prelude.length xs == 499000) $
110112 return (Prelude.length xs)
111113
114+lfilter :: (Int -> Bool) -> Int -> LT.ListT IO Int
115+lfilter = Main.filter
116+
117+lmap :: (Int -> Int) -> Int -> LT.ListT IO Int
118+lmap = Main.map
119+
120+ldrop :: Int -> Int -> LT.ListT IO Int
121+ldrop = Main.drop
122+
123+list_t_basic :: IO Int
124+list_t_basic = do
125+ writeIORef count 0
126+ xs <- LT.toList $ do
127+ LT.fromFoldable [1..1000000 :: Int]
128+ >>= lfilter even
129+ >>= lmap (+1)
130+ >>= ldrop 1000
131+ >>= lmap (+1)
132+ >>= lfilter (\x -> x `mod` 2 == 0)
133+ assert (Prelude.length xs == 499000) $
134+ return (Prelude.length xs)
135+
112136machines_basic :: IO Int
113137machines_basic = do
114138 xs <- M.runT $ M.source [1..1000000]