on master help sign in
Move additional benchmarks under a build flag
commit53b8da31af09740ca944bbd9b7e109f62c0a6e56 authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 6 Sep 2017, 08:56 (9 years ago) parentdeec84b
2 files changed+58−38
asyncly.cabal+18−5 benchmark/Main.hs+40−33
asyncly.cabal+18−5
@@ -63,6 +63,11 @@ test-suite test
6363 transformers >= 0.4 && < 0.6
6464 default-language: Haskell2010
6565
66+flag extra-benchmarks
67+ description: Include comparative benchmarks
68+ manual: True
69+ default: False
70+
6671benchmark bench
6772 type: exitcode-stdio-1.0
6873 main-is: Main.hs
@@ -76,12 +81,20 @@ benchmark bench
7681 , atomic-primops >= 0.8 && < 0.9
7782 , base >= 4.8 && < 5
7883 , criterion >= 1 && < 2
79− , list-t >= 1 && < 2
80− , logict >= 0.6 && < 0.7
81− , machines >= 0.6 && < 0.7
8284 , mtl >= 2.2 && < 3
83− , simple-conduit >= 0.6 && < 0.7
84− , transient >= 0.4 && < 0.6
85+
86+ if impl(ghc < 8.0)
87+ build-depends:
88+ transformers >= 0.4 && < 0.6
89+
90+ if flag(extra-benchmarks)
91+ cpp-options: -DEXTRA_BENCHMARKS
92+ build-depends:
93+ list-t >= 0.4 && < 2
94+ , logict >= 0.6 && < 0.7
95+ , machines >= 0.5 && < 0.7
96+ , simple-conduit >= 0.6 && < 0.7
97+ , transient >= 0.4 && < 0.6
8598 default-language: Haskell2010
8699
87100source-repository head
benchmark/Main.hs+40−33
@@ -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