on master help sign in
separate concurrent nested benchmarks from serial

We want to use -threaded and -N2 options for concurrent benchmarks.

commit17a30053e2fb7169b85cbe201d6be9d5b355815d authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 25 Dec 2019, 23:45 (7 years ago) parent2927661
3 files changed+160−115
benchmark/Nested.hs−52 benchmark/NestedConcurrent.hs+77 streamly.cabal+83−63
benchmark/Nested.hs−52
@@ -46,59 +46,7 @@ main =
4646 , benchIO "breakAfterSome" $ Ops.breakAfterSome wSerially
4747 ]
4848
49− , bgroup "aheadly"
50− [ benchIO "toNullAp" $ Ops.toNullAp aheadly
51− , benchIO "toNull" $ Ops.toNull aheadly
52− , benchIO "toNull3" $ Ops.toNull3 aheadly
53− , benchIO "toList" $ Ops.toList aheadly
54− -- , benchIO "toListSome" $ Ops.toListSome aheadly
55− , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
56− , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
57− , benchIO "filterSome" $ Ops.filterSome aheadly
58− , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
59− ]
60−
61− , bgroup "asyncly"
62− [ benchIO "toNullAp" $ Ops.toNullAp asyncly
63− , benchIO "toNull" $ Ops.toNull asyncly
64− , benchIO "toNull3" $ Ops.toNull3 asyncly
65− , benchIO "toList" $ Ops.toList asyncly
66− -- , benchIO "toListSome" $ Ops.toListSome asyncly
67− , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
68− , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
69− , benchIO "filterSome" $ Ops.filterSome asyncly
70− , benchIO "breakAfterSome" $ Ops.breakAfterSome asyncly
71− ]
72−
73− , bgroup "wAsyncly"
74− [ benchIO "toNullAp" $ Ops.toNullAp wAsyncly
75− , benchIO "toNull" $ Ops.toNull wAsyncly
76− , benchIO "toNull3" $ Ops.toNull3 wAsyncly
77− , benchIO "toList" $ Ops.toList wAsyncly
78− -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
79− , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
80− , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
81− , benchIO "filterSome" $ Ops.filterSome wAsyncly
82− , benchIO "breakAfterSome" $ Ops.breakAfterSome wAsyncly
83− ]
84−
85− , bgroup "parallely"
86− [ benchIO "toNullAp" $ Ops.toNullAp parallely
87− , benchIO "toNull" $ Ops.toNull parallely
88− , benchIO "toNull3" $ Ops.toNull3 parallely
89− , benchIO "toList" $ Ops.toList parallely
90− --, benchIO "toListSome" $ Ops.toListSome parallely
91− , benchIO "filterAllOut" $ Ops.filterAllOut parallely
92− , benchIO "filterAllIn" $ Ops.filterAllIn parallely
93− , benchIO "filterSome" $ Ops.filterSome parallely
94− , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
95− ]
96−
9749 , bgroup "zipSerially"
9850 [ benchIO "toNullAp" $ Ops.toNullAp zipSerially
9951 ]
100−
101− , bgroup "zipAsyncly"
102− [ benchIO "toNullAp" $ Ops.toNullAp zipAsyncly
103− ]
10452 ]
benchmark/NestedConcurrent.hsnew file+77
@@ -0,0 +1,77 @@
1+-- |
2+-- Module : Main
3+-- Copyright : (c) 2018 Harendra Kumar
4+--
5+-- License : BSD3
6+-- Maintainer : streamly@composewell.com
7+
8+import Control.DeepSeq (NFData)
9+import Data.Functor.Identity (Identity, runIdentity)
10+import System.Random (randomRIO)
11+import qualified NestedOps as Ops
12+import Streamly
13+import Gauge
14+
15+benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
16+benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
17+
18+_benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
19+_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
20+
21+main :: IO ()
22+main =
23+ -- TBD Study scaling with 10, 100, 1000 loop iterations
24+ defaultMain
25+ [
26+ bgroup "aheadly"
27+ [ benchIO "toNullAp" $ Ops.toNullAp aheadly
28+ , benchIO "toNull" $ Ops.toNull aheadly
29+ , benchIO "toNull3" $ Ops.toNull3 aheadly
30+ , benchIO "toList" $ Ops.toList aheadly
31+ -- , benchIO "toListSome" $ Ops.toListSome aheadly
32+ , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
33+ , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
34+ , benchIO "filterSome" $ Ops.filterSome aheadly
35+ , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
36+ ]
37+
38+ , bgroup "asyncly"
39+ [ benchIO "toNullAp" $ Ops.toNullAp asyncly
40+ , benchIO "toNull" $ Ops.toNull asyncly
41+ , benchIO "toNull3" $ Ops.toNull3 asyncly
42+ , benchIO "toList" $ Ops.toList asyncly
43+ -- , benchIO "toListSome" $ Ops.toListSome asyncly
44+ , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
45+ , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
46+ , benchIO "filterSome" $ Ops.filterSome asyncly
47+ , benchIO "breakAfterSome" $ Ops.breakAfterSome asyncly
48+ ]
49+
50+ , bgroup "wAsyncly"
51+ [ benchIO "toNullAp" $ Ops.toNullAp wAsyncly
52+ , benchIO "toNull" $ Ops.toNull wAsyncly
53+ , benchIO "toNull3" $ Ops.toNull3 wAsyncly
54+ , benchIO "toList" $ Ops.toList wAsyncly
55+ -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
56+ , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
57+ , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
58+ , benchIO "filterSome" $ Ops.filterSome wAsyncly
59+ , benchIO "breakAfterSome" $ Ops.breakAfterSome wAsyncly
60+ ]
61+
62+ , bgroup "parallely"
63+ [ benchIO "toNullAp" $ Ops.toNullAp parallely
64+ , benchIO "toNull" $ Ops.toNull parallely
65+ , benchIO "toNull3" $ Ops.toNull3 parallely
66+ , benchIO "toList" $ Ops.toList parallely
67+ --, benchIO "toListSome" $ Ops.toListSome parallely
68+ , benchIO "filterAllOut" $ Ops.filterAllOut parallely
69+ , benchIO "filterAllIn" $ Ops.filterAllIn parallely
70+ , benchIO "filterSome" $ Ops.filterSome parallely
71+ , benchIO "breakAfterSome" $ Ops.breakAfterSome parallely
72+ ]
73+
74+ , bgroup "zipAsyncly"
75+ [ benchIO "toNullAp" $ Ops.toNullAp zipAsyncly
76+ ]
77+ ]
streamly.cabal+83−63
@@ -586,69 +586,6 @@ benchmark linear
586586 build-depends: template-haskell >= 2.14 && < 2.16
587587 , inspection-testing >= 0.4 && < 0.5
588588
589−benchmark linear-async
590− import: bench-options-threaded
591− cpp-options: -DLINEAR_ASYNC
592− type: exitcode-stdio-1.0
593− hs-source-dirs: benchmark
594− main-is: LinearAsync.hs
595− other-modules: Streamly.Benchmark.Prelude
596− build-depends:
597− streamly
598− , base >= 4.8 && < 5
599− , deepseq >= 1.4.1 && < 1.5
600− , random >= 1.0 && < 2.0
601− , gauge >= 0.2.4 && < 0.3
602− if impl(ghc < 8.0)
603− build-depends:
604− transformers >= 0.4 && < 0.6
605− if flag(inspection)
606− build-depends: template-haskell >= 2.14 && < 2.16
607− , inspection-testing >= 0.4 && < 0.5
608−
609−benchmark linear-async-long
610− import: bench-options-threaded
611− cpp-options: -DLONG_BENCHMARKS
612− type: exitcode-stdio-1.0
613− hs-source-dirs: benchmark
614− main-is: LinearAsync.hs
615− other-modules: Streamly.Benchmark.Prelude
616− if flag(dev)
617− buildable: True
618− build-depends:
619− streamly
620− , base >= 4.8 && < 5
621− , deepseq >= 1.4.1 && < 1.5
622− , random >= 1.0 && < 2.0
623− , gauge >= 0.2.4 && < 0.3
624− if impl(ghc < 8.0)
625− build-depends:
626− transformers >= 0.4 && < 0.6
627− if flag(inspection)
628− build-depends: template-haskell >= 2.14 && < 2.16
629− , inspection-testing >= 0.4 && < 0.5
630− else
631− buildable: False
632−
633−benchmark linear-rate
634− import: bench-options-threaded
635− type: exitcode-stdio-1.0
636− hs-source-dirs: benchmark
637− main-is: LinearRate.hs
638− other-modules: Streamly.Benchmark.Prelude
639− build-depends:
640− streamly
641− , base >= 4.8 && < 5
642− , deepseq >= 1.4.1 && < 1.5
643− , random >= 1.0 && < 2.0
644− , gauge >= 0.2.4 && < 0.3
645− if impl(ghc < 8.0)
646− build-depends:
647− transformers >= 0.4 && < 0.6
648− if flag(inspection)
649− build-depends: template-haskell >= 2.14 && < 2.16
650− , inspection-testing >= 0.4 && < 0.5
651−
652589benchmark nested
653590 import: bench-options
654591 type: exitcode-stdio-1.0
@@ -749,6 +686,89 @@ benchmark fileio
749686 build-depends: template-haskell >= 2.14 && < 2.16
750687 , inspection-testing >= 0.4 && < 0.5
751688
689+-------------------------------------------------------------------------------
690+-- Threaded Benchmarks
691+-------------------------------------------------------------------------------
692+
693+benchmark linear-async
694+ import: bench-options-threaded
695+ cpp-options: -DLINEAR_ASYNC
696+ type: exitcode-stdio-1.0
697+ hs-source-dirs: benchmark
698+ main-is: LinearAsync.hs
699+ other-modules: Streamly.Benchmark.Prelude
700+ build-depends:
701+ streamly
702+ , base >= 4.8 && < 5
703+ , deepseq >= 1.4.1 && < 1.5
704+ , random >= 1.0 && < 2.0
705+ , gauge >= 0.2.4 && < 0.3
706+ if impl(ghc < 8.0)
707+ build-depends:
708+ transformers >= 0.4 && < 0.6
709+ if flag(inspection)
710+ build-depends: template-haskell >= 2.14 && < 2.16
711+ , inspection-testing >= 0.4 && < 0.5
712+
713+benchmark linear-async-long
714+ import: bench-options-threaded
715+ cpp-options: -DLONG_BENCHMARKS
716+ type: exitcode-stdio-1.0
717+ hs-source-dirs: benchmark
718+ main-is: LinearAsync.hs
719+ other-modules: Streamly.Benchmark.Prelude
720+ if flag(dev)
721+ buildable: True
722+ build-depends:
723+ streamly
724+ , base >= 4.8 && < 5
725+ , deepseq >= 1.4.1 && < 1.5
726+ , random >= 1.0 && < 2.0
727+ , gauge >= 0.2.4 && < 0.3
728+ if impl(ghc < 8.0)
729+ build-depends:
730+ transformers >= 0.4 && < 0.6
731+ if flag(inspection)
732+ build-depends: template-haskell >= 2.14 && < 2.16
733+ , inspection-testing >= 0.4 && < 0.5
734+ else
735+ buildable: False
736+
737+benchmark nested-concurrent
738+ import: bench-options-threaded
739+ type: exitcode-stdio-1.0
740+ hs-source-dirs: benchmark
741+ main-is: NestedConcurrent.hs
742+ other-modules: NestedOps
743+ build-depends:
744+ streamly
745+ , base >= 4.8 && < 5
746+ , deepseq >= 1.4.1 && < 1.5
747+ , random >= 1.0 && < 2.0
748+ , gauge >= 0.2.4 && < 0.3
749+ if impl(ghc < 8.0)
750+ build-depends:
751+ transformers >= 0.4 && < 0.6
752+
753+benchmark linear-rate
754+ import: bench-options-threaded
755+ type: exitcode-stdio-1.0
756+ hs-source-dirs: benchmark
757+ main-is: LinearRate.hs
758+ other-modules: Streamly.Benchmark.Prelude
759+ build-depends:
760+ streamly
761+ , base >= 4.8 && < 5
762+ , deepseq >= 1.4.1 && < 1.5
763+ , random >= 1.0 && < 2.0
764+ , gauge >= 0.2.4 && < 0.3
765+ if impl(ghc < 8.0)
766+ build-depends:
767+ transformers >= 0.4 && < 0.6
768+ if flag(inspection)
769+ build-depends: template-haskell >= 2.14 && < 2.16
770+ , inspection-testing >= 0.4 && < 0.5
771+
752772benchmark concurrent
753773 import: bench-options-threaded
754774 type: exitcode-stdio-1.0