@@ -12,6 +12,8 @@ import Data.IORef (IORef, newIORef, writeIORef)
1212import System.IO.Unsafe (unsafePerformIO)
1313
1414import qualified Asyncly as A
15+
16+#ifdef EXTRA_BENCHMARKS
1517import qualified Conduit.Simple as S
1618import qualified Control.Monad.Logic as LG
1719import qualified Data.Machine as M
@@ -20,6 +22,7 @@ import qualified Transient.Internals as T
2022import qualified Transient.Indeterminism as T
2123#endif
2224import qualified ListT as LT
25+#endif
2326
2427main :: IO ()
2528main = do
@@ -33,6 +36,7 @@ main = do
3336 , bench "asyncly-interleaved-nil" $ nfIO (asyncly_nil (A.<=>))
3437 , bench "asyncly-parleft-nil" $ nfIO (asyncly_nil (A.<|))
3538 , bench "asyncly-parinterleaved-nil" $ nfIO (asyncly_nil (A.<|>))
39+#ifdef EXTRA_BENCHMARKS
3640#if MIN_VERSION_transient(0,5,1)
3741 , bench "transient" $ nfIO transient_basic
3842 , bench "transient-nil" $ nfIO transient_nil
@@ -41,6 +45,7 @@ main = do
4145 , bench "list-t" $ nfIO list_t_basic
4246 , bench "simple-conduit" $ nfIO simple_conduit_basic
4347 , bench "machines" $ nfIO machines_basic
48+#endif
4449 ]
4550 ]
4651
@@ -64,39 +69,6 @@ drop num x = do
6469 guard mn
6570 return x
6671
67−#if MIN_VERSION_transient(0,5,1)
68−tmap :: (a -> Int) -> a -> T.TransIO Int
69−tmap = Main.map
70−
71−tfilter :: (a -> Bool) -> a -> T.TransIO a
72−tfilter = Main.filter
73−
74−tdrop :: Int -> Int -> T.TransIO Int
75−tdrop = Main.drop
76−
77−transient_basic :: IO (Maybe Int)
78−
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]
83− >>= tfilter even
84− >>= tmap (+1)
85− >>= tdrop 100
86− >>= tmap (+1)
87− >>= tfilter (\x -> x `mod` 2 == 0)
88−
89− assert (Prelude.length xs == 49900) $
90− T.exit (Prelude.length xs)
91−
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)
98−#endif
99−
10072amap :: (Int -> Int) -> Int -> A.AsyncT IO Int
10173amap = Main.map
10274
@@ -132,6 +104,40 @@ asyncly_nil f = do
132104 assert (Prelude.length xs == 100000) $
133105 return (Prelude.length xs)
134106
107+#ifdef EXTRA_BENCHMARKS
108+#if MIN_VERSION_transient(0,5,1)
109+tmap :: (a -> Int) -> a -> T.TransIO Int
110+tmap = Main.map
111+
112+tfilter :: (a -> Bool) -> a -> T.TransIO a
113+tfilter = Main.filter
114+
115+tdrop :: Int -> Int -> T.TransIO Int
116+tdrop = Main.drop
117+
118+transient_basic :: IO (Maybe Int)
119+
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]
124+ >>= tfilter even
125+ >>= tmap (+1)
126+ >>= tdrop 100
127+ >>= tmap (+1)
128+ >>= tfilter (\x -> x `mod` 2 == 0)
129+
130+ assert (Prelude.length xs == 49900) $
131+ T.exit (Prelude.length xs)
132+
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)
139+#endif
140+
135141lfilter :: (Int -> Bool) -> Int -> LT.ListT IO Int
136142lfilter = Main.filter
137143
@@ -199,3 +205,4 @@ machines_basic = do
199205 M.~> M.filtered (\x -> x `mod` 2 == 0)
200206 assert (Prelude.length xs == 49900) $
201207 return (Prelude.length (xs ::[Int]))
208+#endif