@@ -12,6 +12,8 @@ import Data.IORef (IORef, newIORef, writeIORef)
12import System.IO.Unsafe (unsafePerformIO)
12import System.IO.Unsafe (unsafePerformIO)
14import qualified Asyncly as A
14import qualified Asyncly as A
16+#ifdef EXTRA_BENCHMARKS
15import qualified Conduit.Simple as S
17import qualified Conduit.Simple as S
16import qualified Control.Monad.Logic as LG
18import qualified Control.Monad.Logic as LG
17import qualified Data.Machine as M
19import qualified Data.Machine as M
@@ -20,6 +22,7 @@ import qualified Transient.Internals as T
20import qualified Transient.Indeterminism as T
22import qualified Transient.Indeterminism as T
22import qualified ListT as LT
24import qualified ListT as LT
24main :: IO ()
27main :: IO ()
@@ -33,6 +36,7 @@ main = do
33 , bench "asyncly-interleaved-nil" $ nfIO (asyncly_nil (A.<=>))
36 , bench "asyncly-interleaved-nil" $ nfIO (asyncly_nil (A.<=>))
34 , bench "asyncly-parleft-nil" $ nfIO (asyncly_nil (A.<|))
37 , bench "asyncly-parleft-nil" $ nfIO (asyncly_nil (A.<|))
35 , bench "asyncly-parinterleaved-nil" $ nfIO (asyncly_nil (A.<|>))
38 , bench "asyncly-parinterleaved-nil" $ nfIO (asyncly_nil (A.<|>))
39+#ifdef EXTRA_BENCHMARKS
36#if MIN_VERSION_transient(0,5,1)
40#if MIN_VERSION_transient(0,5,1)
37 , bench "transient" $ nfIO transient_basic
41 , bench "transient" $ nfIO transient_basic
38 , bench "transient-nil" $ nfIO transient_nil
42 , bench "transient-nil" $ nfIO transient_nil
@@ -41,6 +45,7 @@ main = do
41 , bench "list-t" $ nfIO list_t_basic
45 , bench "list-t" $ nfIO list_t_basic
42 , bench "simple-conduit" $ nfIO simple_conduit_basic
46 , bench "simple-conduit" $ nfIO simple_conduit_basic
43 , bench "machines" $ nfIO machines_basic
47 , bench "machines" $ nfIO machines_basic
@@ -64,39 +69,6 @@ drop num x = do
67−#if MIN_VERSION_transient(0,5,1)
68−tmap :: (a -> Int) -> a -> T.TransIO Int
71−tfilter :: (a -> Bool) -> a -> T.TransIO a
74−tdrop :: Int -> Int -> T.TransIO Int
77−transient_basic :: IO (Maybe Int)
79−transient_basic = T.keep' $ T.threads 0 $ do
80− liftIO $ writeIORef count 0
81− xs <- T.group 49900 $ do
82− T.choose [1..100000 :: Int]
87− >>= tfilter (\x -> x `mod` 2 == 0)
89− assert (Prelude.length xs == 49900) $
90− T.exit (Prelude.length xs)
92−transient_nil :: IO (Maybe Int)
93−transient_nil = T.keep' $ T.threads 0 $ do
94− xs <- T.group 49900 $ do
95− T.choose [1..100000 :: Int]
96− assert (Prelude.length xs == 49900) $
97− T.exit (Prelude.length xs)
100amap :: (Int -> Int) -> Int -> A.AsyncT IO Int
72amap :: (Int -> Int) -> Int -> A.AsyncT IO Int
101amap = Main.map
73amap = Main.map
@@ -132,6 +104,40 @@ asyncly_nil f = do
132 assert (Prelude.length xs == 100000) $
104 assert (Prelude.length xs == 100000) $
133 return (Prelude.length xs)
105 return (Prelude.length xs)
107+#ifdef EXTRA_BENCHMARKS
108+#if MIN_VERSION_transient(0,5,1)
109+tmap :: (a -> Int) -> a -> T.TransIO Int
112+tfilter :: (a -> Bool) -> a -> T.TransIO a
113+tfilter = Main.filter
115+tdrop :: Int -> Int -> T.TransIO Int
118+transient_basic :: IO (Maybe Int)
120+transient_basic = T.keep' $ T.threads 0 $ do
121+ liftIO $ writeIORef count 0
122+ xs <- T.group 49900 $ do
123+ T.choose [1..100000 :: Int]
128+ >>= tfilter (\x -> x `mod` 2 == 0)
130+ assert (Prelude.length xs == 49900) $
131+ T.exit (Prelude.length xs)
133+transient_nil :: IO (Maybe Int)
134+transient_nil = T.keep' $ T.threads 0 $ do
135+ xs <- T.group 49900 $ do
136+ T.choose [1..100000 :: Int]
137+ assert (Prelude.length xs == 49900) $
138+ T.exit (Prelude.length xs)
135lfilter :: (Int -> Bool) -> Int -> LT.ListT IO Int
141lfilter :: (Int -> Bool) -> Int -> LT.ListT IO Int
136lfilter = Main.filter
142lfilter = Main.filter
@@ -199,3 +205,4 @@ machines_basic = do
199 M.~> M.filtered (\x -> x `mod` 2 == 0)
205 M.~> M.filtered (\x -> x `mod` 2 == 0)
200 assert (Prelude.length xs == 49900) $
206 assert (Prelude.length xs == 49900) $
201 return (Prelude.length (xs ::[Int]))
207 return (Prelude.length (xs ::[Int]))