git.iko.soy/effects-benchmarks
on master help sign in
Use weigh for allocations testing
commiteb051408c1e2777baff8a4eddc0abffa910b490c authorPatrick Thomson <patrickt@github.com> dateMon 6 May 2019, 13:03 (7 years ago) parentf50cd09
2 files changed+45−17
effects-benchmarks.cabal+11 src/Main.hs+34−17
effects-benchmarks.cabal+11
@@ -33,6 +33,14 @@ library instances-for-shallow
3333 , Shallow.Stateful
3434 , Shallow.StatefulExcept
3535
36+library instances-for-exteff
37+ import: shared
38+ hs-source-dirs: instances
39+ exposed-modules: ExtEff.Stateful
40+ , ExtEff.StatefulExcept
41+ , ExtEff.HTTP
42+ build-depends: extensible-effects ^>= 5.0.0.1
43+
3644library instances-for-mtl
3745 import: shared
3846 hs-source-dirs: instances
@@ -75,8 +83,10 @@ benchmark effects-benchmarks
7583 , instances-for-freer-simple
7684 , instances-for-polysemy
7785 , instances-for-shallow
86+ , instances-for-exteff
7887 , dump-core
7988 , gauge
89+ , weigh
8090 , polysemy
8191 main-is: Main.hs
8292 mixins: benchmark-signatures (Bench.Countdown as MTL.Countdown, Bench.HTTP as MTL.HTTPM) requires (Bench.Signature.Stateful as MTLStateful, Bench.Signature.StatefulExcept as MTL.StatefulExcept, Bench.Signature.HTTP as MTL.HTTP)
@@ -84,3 +94,4 @@ benchmark effects-benchmarks
8494 , benchmark-signatures (Bench.Countdown as Simple.Countdown, Bench.HTTP as Simple.HTTPM) requires (Bench.Signature.Stateful as FSStateful, Bench.Signature.StatefulExcept as Freer.StatefulExcept, Bench.Signature.HTTP as Freer.HTTP)
8595 , benchmark-signatures (Bench.Countdown as Shallow.Countdown, Bench.HTTP as Shallow.HTTPM) requires (Bench.Signature.Stateful as Shallow.Stateful, Bench.Signature.StatefulExcept as Shallow.StatefulExcept, Bench.Signature.HTTP as Shallow.HTTP)
8696 , benchmark-signatures (Bench.Countdown as Poly.Countdown, Bench.HTTP as Poly.HTTPM) requires (Bench.Signature.Stateful as Poly.Stateful, Bench.Signature.StatefulExcept as Poly.StatefulExcept, Bench.Signature.HTTP as Poly.HTTP)
97+ , benchmark-signatures (Bench.Countdown as ExtEff.Countdown, Bench.HTTP as ExtEff.HTTPM) requires (Bench.Signature.Stateful as ExtEff.Stateful, Bench.Signature.StatefulExcept as ExtEff.StatefulExcept, Bench.Signature.HTTP as ExtEff.HTTP)
src/Main.hs+34−17
@@ -4,46 +4,63 @@ module Main where
44
55import Gauge (bench, bgroup, nf, nfAppIO)
66import Gauge.Main (defaultMain)
7+import qualified Weigh
78
89import qualified Fused.Countdown as Fused
910import qualified Simple.Countdown as Simple
1011import qualified Shallow.Countdown as Shallow
1112import qualified MTL.Countdown as MTL
1213import qualified Poly.Countdown as Poly
14+import qualified ExtEff.Countdown as ExtEff
1315
1416import qualified Fused.HTTPM as Fused
1517import qualified Simple.HTTPM as Simple
1618import qualified MTL.HTTPM as MTL
1719import qualified Shallow.HTTPM as Shallow
1820import qualified Poly.HTTPM as Poly
21+import qualified ExtEff.HTTPM as ExtEff
22+
23+#define MEMSUITE(nam,v) sequence_ [ Weigh.func "fused-effects" Fused.nam v \
24+ , Weigh.func "mtl" MTL.nam v \
25+ , Weigh.func "polysemy" Poly.nam v \
26+ , Weigh.func "freer-simple" Simple.nam v \
27+ , Weigh.func "extensible-effects" ExtEff.nam v \
28+ , Weigh.func "shallow" Shallow.nam v ]
1929
2030#define SUITE(nam,v) [ bench "fused-effects" (nf Fused.nam v) \
2131 , bench "mtl" (nf MTL.nam v) \
2232 , bench "polysemy" (nf Poly.nam v) \
2333 , bench "freer-simple" (nf Simple.nam v) \
34+ , bench "extensible-effects" (nf ExtEff.nam v) \
2435 , bench "shallow" (nf Shallow.nam v) ]
2536
37+wruns :: Int
38+wruns = 1
39+
2640runs :: Int
2741runs = 10000
2842
2943main :: IO ()
30−main = defaultMain
31− [
32− bgroup "Countdown"
33− [ bgroup "Put" SUITE(countDownPut, runs)
34− , bgroup "Put+Exc" SUITE(countDownExc, runs)
35− ]
36− , bgroup "HTTP"
37− [ bench "fused-effects" (nfAppIO Fused.doHTTP runs)
38− , bench "polysemy" (nfAppIO Poly.doHTTP runs)
39− , bench "Deep embedding" (nfAppIO MTL.doHTTP runs)
40− , bench "Shallow embedding" (nfAppIO Shallow.doHTTP runs)
41− , bench "freer-simple" (nfAppIO Simple.doHTTP runs)
44+main = do
45+ putStrLn "*** Time benchmarks ***"
46+ defaultMain
47+ [
48+ bgroup "Countdown"
49+ [ bgroup "Put" SUITE(countDownPut, runs)
50+ , bgroup "Put+Exc" SUITE(countDownExc, runs)
51+ ]
52+ , bgroup "HTTP"
53+ [ bench "fused-effects" (nfAppIO Fused.doHTTP runs)
54+ , bench "polysemy" (nfAppIO Poly.doHTTP runs)
55+ , bench "extensible-effects" (nfAppIO ExtEff.doHTTP runs)
56+ , bench "Deep embedding" (nfAppIO MTL.doHTTP runs)
57+ , bench "Shallow embedding" (nfAppIO Shallow.doHTTP runs)
58+ , bench "freer-simple" (nfAppIO Simple.doHTTP runs)
59+ ]
4260 ]
43− ]
4461
45−bareDown :: Int -> (Int, Int)
46−bareDown st = if st <= 0 then (st, st) else bareDown (st - 1)
62+ putStrLn "*** Space benchmarks (these will take some time to run) ***"
63+ Weigh.mainWith $ do
64+ Weigh.wgroup "Countdown" $ MEMSUITE(countDownPut, wruns)
65+ Weigh.wgroup "Countdown + exc" $ MEMSUITE(countDownExc, wruns)
4766
48−bareDownExc :: Int -> Either String (Int, Int)
49−bareDownExc st = if st <= 0 then Left "what" else bareDownExc (st - 1)