on master help sign in
Added Cabal flags for benchmark suite (#15)
fb883c9Mann mit Hut
bench/Countdown.hs+7−1
@@ -2,7 +2,6 @@
2module Countdown where
2module Countdown where
3
3
4import Control.Monad.ST
4import Control.Monad.ST
5−import Data.Functor.Identity
6import Data.STRef
5import Data.STRef
7
6
8-- eff
7-- eff
@@ -32,8 +31,11 @@ import qualified Control.Carrier.State.Strict as FE
32#endif
31#endif
33
32
34-- mtl
33-- mtl
34+#ifdef VERSION_mtl
35import qualified Control.Monad.Reader as M
35import qualified Control.Monad.Reader as M
36import qualified Control.Monad.State as M
36import qualified Control.Monad.State as M
37+import Data.Functor.Identity
38+#endif
37
39
38-- polysemy
40-- polysemy
39#ifdef VERSION_polysemy
41#ifdef VERSION_polysemy
@@ -72,6 +74,8 @@ countdownST n = runST $ do
72----------------------------------------
74----------------------------------------
73-- mtl
75-- mtl
74
76
77+#ifdef VERSION_mtl
78+
75programMtl :: M.MonadState Integer m => m Integer
79programMtl :: M.MonadState Integer m => m Integer
76programMtl = do
80programMtl = do
77 n <- M.get @Integer
81 n <- M.get @Integer
@@ -94,6 +98,8 @@ countdownMtlDeep n = runIdentity
94 where
98 where
95 runR = flip M.runReaderT ()
99 runR = flip M.runReaderT ()
96
100
101+#endif
102+
97----------------------------------------
103----------------------------------------
98-- effectful (pure)
104-- effectful (pure)
99
105
bench/FileSizes.hs+14−3
@@ -6,7 +6,6 @@ module FileSizes where
6import Control.Exception
6import Control.Exception
7import Control.Monad.IO.Class
7import Control.Monad.IO.Class
8import Data.IORef
8import Data.IORef
9−import Data.Tuple
10import System.Posix
9import System.Posix
11
10
12-- effectful
11-- effectful
@@ -27,8 +26,10 @@ import qualified Control.Monad.Freer.State as FS
27#endif
26#endif
28
27
29-- mtl
28-- mtl
29+#ifdef VERSION_mtl
30import qualified Control.Monad.State as M
30import qualified Control.Monad.State as M
31import qualified Control.Monad.Reader as M
31import qualified Control.Monad.Reader as M
32+#endif
32
33
33-- polysemy
34-- polysemy
34#ifdef VERSION_polysemy
35#ifdef VERSION_polysemy
@@ -155,10 +156,13 @@ eff_runLogging
155 :: L.Eff (Eff_Logging : es) a
156 :: L.Eff (Eff_Logging : es) a
156 -> L.Eff es (a, [String])
157 -> L.Eff es (a, [String])
157eff_runLogging
158eff_runLogging
158− = fmap swap . L.runState [] . L.interpret \case
159+ = fmap eff_swap . L.runState [] . L.interpret \case
159 Eff_logMsg msg -> L.modify (msg :)
160 Eff_logMsg msg -> L.modify (msg :)
160 . L.lift
161 . L.lift
161
162
163+eff_swap :: (a, b) -> (b, a)
164+eff_swap (x, y) = (y, x)
165+
162----------
166----------
163
167
164eff_calculateFileSize
168eff_calculateFileSize
@@ -263,6 +267,8 @@ fs_calculateFileSizesDeep = FS.runM
263----------------------------------------
267----------------------------------------
264-- mtl
268-- mtl
265
269
270+#ifdef VERSION_mtl
271+
266class Monad m => MonadFile m where
272class Monad m => MonadFile m where
267 mtl_tryFileSize :: FilePath -> m (Maybe Int)
273 mtl_tryFileSize :: FilePath -> m (Maybe Int)
268
274
@@ -329,6 +335,8 @@ mtl_calculateFileSizesDeep
329 where
335 where
330 runR = flip M.runReaderT ()
336 runR = flip M.runReaderT ()
331
337
338+#endif
339+
332----------------------------------------
340----------------------------------------
333-- polysemy
341-- polysemy
334
342
@@ -351,9 +359,12 @@ poly_logMsg :: P.Member Poly_Logging es => String -> P.Sem es ()
351poly_logMsg = P.send . Poly_logMsg
359poly_logMsg = P.send . Poly_logMsg
352
360
353poly_runLogging :: P.Sem (Poly_Logging : es) a -> P.Sem es (a, [String])
361poly_runLogging :: P.Sem (Poly_Logging : es) a -> P.Sem es (a, [String])
354−poly_runLogging = fmap swap . P.runState [] . P.reinterpret \case
362+poly_runLogging = fmap poly_swap . P.runState [] . P.reinterpret \case
355 Poly_logMsg msg -> P.modify (msg :)
363 Poly_logMsg msg -> P.modify (msg :)
356
364
365+poly_swap :: (a, b) -> (b, a)
366+poly_swap (x, y) = (y, x)
367+
357----------
368----------
358
369
359poly_calculateFileSize
370poly_calculateFileSize
bench/Main.hs+8
@@ -36,7 +36,9 @@ countdown n = bgroup (show n)
36#ifdef VERSION_eff
36#ifdef VERSION_eff
37 , bench "eff" $ nf countdownEff n
37 , bench "eff" $ nf countdownEff n
38#endif
38#endif
39+#ifdef VERSION_mtl
39 , bench "mtl" $ nf countdownMtl n
40 , bench "mtl" $ nf countdownMtl n
41+#endif
40#ifdef VERSION_fused_effects
42#ifdef VERSION_fused_effects
41 , bench "fused-effects" $ nf countdownFusedEffects n
43 , bench "fused-effects" $ nf countdownFusedEffects n
42#endif
44#endif
@@ -58,7 +60,9 @@ countdown n = bgroup (show n)
58#ifdef VERSION_polysemy
60#ifdef VERSION_polysemy
59 , bench "polysemy" $ nf countdownPolysemyDeep n
61 , bench "polysemy" $ nf countdownPolysemyDeep n
60#endif
62#endif
63+#ifdef VERSION_mtl
61 , bench "mtl" $ nf countdownMtlDeep n
64 , bench "mtl" $ nf countdownMtlDeep n
65+#endif
62#ifdef VERSION_fused_effects
66#ifdef VERSION_fused_effects
63 , bench "fused-effects" $ nf countdownFusedEffectsDeep n
67 , bench "fused-effects" $ nf countdownFusedEffectsDeep n
64#endif
68#endif
@@ -73,7 +77,9 @@ filesize n = bgroup (show n)
73#ifdef VERSION_freer_simple
77#ifdef VERSION_freer_simple
74 , bench "freer-simple" $ nfAppIO fs_calculateFileSizes (take n files)
78 , bench "freer-simple" $ nfAppIO fs_calculateFileSizes (take n files)
75#endif
79#endif
80+#ifdef VERSION_mtl
76 , bench "mtl" $ nfAppIO mtl_calculateFileSizes (take n files)
81 , bench "mtl" $ nfAppIO mtl_calculateFileSizes (take n files)
82+#endif
77#ifdef VERSION_eff
83#ifdef VERSION_eff
78 , bench "eff" $ nfAppIO eff_calculateFileSizes (take n files)
84 , bench "eff" $ nfAppIO eff_calculateFileSizes (take n files)
79#endif
85#endif
@@ -92,7 +98,9 @@ filesize n = bgroup (show n)
92#ifdef VERSION_polysemy
98#ifdef VERSION_polysemy
93 , bench "polysemy" $ nfAppIO poly_calculateFileSizesDeep (take n files)
99 , bench "polysemy" $ nfAppIO poly_calculateFileSizesDeep (take n files)
94#endif
100#endif
101+#ifdef VERSION_mtl
95 , bench "mtl" $ nfAppIO mtl_calculateFileSizesDeep (take n files)
102 , bench "mtl" $ nfAppIO mtl_calculateFileSizesDeep (take n files)
103+#endif
96 ]
104 ]
97 ]
105 ]
98 where
106 where
effectful.cabal+13−7
@@ -22,6 +22,10 @@ source-repository head
22 type: git
22 type: git
23 location: https://github.com/arybczak/effectful.git
23 location: https://github.com/arybczak/effectful.git
24
24
25+flag benchmark-foreign-libraries
26+ description: Include other effect libraries in the benchmarks
27+ default: False
28+
25common language
29common language
26 ghc-options: -Wall -Wcompat
30 ghc-options: -Wall -Wcompat
27
31
@@ -128,18 +132,20 @@ benchmark bench
128
132
129 ghc-options: -threaded -rtsopts -with-rtsopts=-T
133 ghc-options: -threaded -rtsopts -with-rtsopts=-T
130
134
135+ if flag(benchmark-foreign-libraries)
136+ build-depends: mtl
137+
131− if impl(ghc < 9)
138+ if impl(ghc < 9)
132− build-depends: freer-simple
139+ build-depends: freer-simple
133
140
134− if impl(ghc < 9.2)
141+ if impl(ghc < 9.2)
135− build-depends: fused-effects
142+ build-depends: fused-effects
136
143
137− if impl(ghc < 9)
144+ if impl(ghc < 9)
138− build-depends: polysemy
145+ build-depends: polysemy
139
146
140 build-depends: base <5
147 build-depends: base <5
141 , effectful
148 , effectful
142− , mtl
143 , tasty-bench
149 , tasty-bench
144 , transformers
150 , transformers
145 , unix
151 , unix