on master help sign in
separate the rate benchmarks
acbfca3Harendra Kumar
bench.sh+1−1
@@ -3,7 +3,7 @@
3print_help () {
3print_help () {
4 echo "Usage: $0 "
4 echo "Usage: $0 "
5 echo " [--compare] [--base commit] [--candidate commit]"
5 echo " [--compare] [--base commit] [--candidate commit]"
6− echo " [--benchmark <linear|nested|base>]"
6+ echo " [--benchmark <linear|linear-async|linear-rate|nested|base>]"
7 echo " [--graphs]"
7 echo " [--graphs]"
8 echo " [--slow]"
8 echo " [--slow]"
9 echo " [--no-measure]"
9 echo " [--no-measure]"
benchmark/Chart.hs+10−1
@@ -20,7 +20,7 @@ import BenchGraph
20-- Command line parsing
20-- Command line parsing
21------------------------------------------------------------------------------
21------------------------------------------------------------------------------
22
22
23−data BenchType = Linear | LinearAsync | Nested | Base
23+data BenchType = Linear | LinearAsync | LinearRate | Nested | Base
24
24
25data Options = Options
25data Options = Options
26 { genGraphs :: Bool
26 { genGraphs :: Bool
@@ -51,6 +51,7 @@ parseBench = do
51 case x of
51 case x of
52 Just "linear" -> setBenchType Linear
52 Just "linear" -> setBenchType Linear
53 Just "linear-async" -> setBenchType LinearAsync
53 Just "linear-async" -> setBenchType LinearAsync
54+ Just "linear-rate" -> setBenchType LinearRate
54 Just "nested" -> setBenchType Nested
55 Just "nested" -> setBenchType Nested
55 Just "base" -> setBenchType Base
56 Just "base" -> setBenchType Base
56 Just str -> do
57 Just str -> do
@@ -138,6 +139,11 @@ makeLinearAsyncGraphs cfg inputFile = do
138 putStrLn "Not implemented"
139 putStrLn "Not implemented"
139 return ()
140 return ()
140
141
142+makeLinearRateGraphs :: Config -> String -> IO ()
143+makeLinearRateGraphs cfg inputFile = do
144+ putStrLn "Not implemented"
145+ return ()
146+
141------------------------------------------------------------------------------
147------------------------------------------------------------------------------
142-- Charts for base streams
148-- Charts for base streams
143------------------------------------------------------------------------------
149------------------------------------------------------------------------------
@@ -183,6 +189,9 @@ main = do
183 LinearAsync -> benchShow opts cfg makeLinearAsyncGraphs
189 LinearAsync -> benchShow opts cfg makeLinearAsyncGraphs
184 "charts/linear-async/results.csv"
190 "charts/linear-async/results.csv"
185 "charts/linear-async"
191 "charts/linear-async"
192+ LinearRate -> benchShow opts cfg makeLinearRateGraphs
193+ "charts/linear-rate/results.csv"
194+ "charts/linear-rate"
186 Nested -> benchShow opts cfg makeNestedGraphs
195 Nested -> benchShow opts cfg makeNestedGraphs
187 "charts/nested/results.csv"
196 "charts/nested/results.csv"
188 "charts/nested"
197 "charts/nested"
benchmark/LinearAsync.hs−23
@@ -52,23 +52,6 @@ main = do
52 , benchSrcIO asyncly "unfoldrM maxBuffer 1 (1000 ops)"
52 , benchSrcIO asyncly "unfoldrM maxBuffer 1 (1000 ops)"
53 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
53 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
54 ]
54 ]
55− , bgroup "asyncly/rate"
56− [ -- benchIO "unfoldr" $ Ops.toNull asyncly
57− benchSrcIO asyncly "unfoldrM" Ops.sourceUnfoldrM
58− , benchSrcIO asyncly "unfoldrM/Nothing"
59− (rate Nothing . Ops.sourceUnfoldrM)
60− , benchSrcIO asyncly "unfoldrM/AvgRate/1,000,000"
61− (avgRate 1000000 . Ops.sourceUnfoldrM)
62− , benchSrcIO asyncly "unfoldrM/AvgRate/3,000,000"
63− (avgRate 3000000 . Ops.sourceUnfoldrM)
64− , benchSrcIO asyncly "unfoldrM/AvgRate/10,000,000/maxThreads1"
65− (maxThreads 1 . avgRate 10000000 . Ops.sourceUnfoldrM)
66− -- XXX arbitrarily large rate should be the same as rate Nothing
67− , benchSrcIO asyncly "unfoldrM/AvgRate/10,000,000"
68− (avgRate 10000000 . Ops.sourceUnfoldrM)
69− , benchSrcIO asyncly "unfoldrM/AvgRate/20,000,000"
70− (avgRate 20000000 . Ops.sourceUnfoldrM)
71− ]
72 , bgroup "wAsyncly"
55 , bgroup "wAsyncly"
73 [ -- benchIO "unfoldr" $ Ops.toNull wAsyncly
56 [ -- benchIO "unfoldr" $ Ops.toNull wAsyncly
74 benchSrcIO wAsyncly "unfoldrM" Ops.sourceUnfoldrM
57 benchSrcIO wAsyncly "unfoldrM" Ops.sourceUnfoldrM
@@ -93,12 +76,6 @@ main = do
93 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
76 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
94 -- , benchSrcIO aheadly "fromFoldable" Ops.sourceFromFoldable
77 -- , benchSrcIO aheadly "fromFoldable" Ops.sourceFromFoldable
95 ]
78 ]
96− , bgroup "aheadly/rate"
97− [
98− -- XXX arbitrarily large maxRate should be the same as maxRate -1
99− benchSrcIO aheadly "unfoldrM rate AvgRate 1000000"
100− (avgRate 1000000 . Ops.sourceUnfoldrM)
101− ]
102 -- XXX need to use smaller streams to finish in reasonable time
79 -- XXX need to use smaller streams to finish in reasonable time
103 , bgroup "parallely"
80 , bgroup "parallely"
104 [ --benchIO "unfoldr" $ Ops.toNull parallely
81 [ --benchIO "unfoldr" $ Ops.toNull parallely
benchmark/LinearRate.hsnew file+60
@@ -0,0 +1,60 @@
1+-- |
2+-- Module : Main
3+-- Copyright : (c) 2018 Harendra Kumar
4+--
5+-- License : BSD3
6+-- Maintainer : harendra.kumar@gmail.com
7+
8+-- Rate benchmarks are kept separate because they need more running time to
9+-- provide stable results.
10+
11+-- import Data.Functor.Identity (Identity, runIdentity)
12+import System.Random (randomRIO)
13+import qualified LinearOps as Ops
14+
15+import Streamly
16+import Gauge
17+
18+-- | Takes a source, and uses it with a default drain/fold method.
19+{-# INLINE benchSrcIO #-}
20+benchSrcIO
21+ :: (t IO Int -> SerialT IO Int)
22+ -> String
23+ -> (Int -> t IO Int)
24+ -> Benchmark
25+benchSrcIO t name f
26+ = bench name $ nfIO $ randomRIO (1,1) >>= Ops.toNull t . f
27+
28+{-
29+_benchId :: NFData b => String -> (Ops.Stream m Int -> Identity b) -> Benchmark
30+_benchId name f = bench name $ nf (runIdentity . f) (Ops.source 10)
31+-}
32+
33+main :: IO ()
34+main = do
35+ defaultMain
36+ -- XXX arbitrarily large rate should be the same as rate Nothing
37+ [ bgroup "avgrate"
38+ [ bgroup "asyncly"
39+ [ -- benchIO "unfoldr" $ Ops.toNull asyncly
40+ benchSrcIO asyncly "unfoldrM" Ops.sourceUnfoldrM
41+ , benchSrcIO asyncly "unfoldrM/Nothing"
42+ (rate Nothing . Ops.sourceUnfoldrM)
43+ , benchSrcIO asyncly "unfoldrM/1,000,000"
44+ (avgRate 1000000 . Ops.sourceUnfoldrM)
45+ , benchSrcIO asyncly "unfoldrM/3,000,000"
46+ (avgRate 3000000 . Ops.sourceUnfoldrM)
47+ , benchSrcIO asyncly "unfoldrM/10,000,000/maxThreads1"
48+ (maxThreads 1 . avgRate 10000000 . Ops.sourceUnfoldrM)
49+ , benchSrcIO asyncly "unfoldrM/10,000,000"
50+ (avgRate 10000000 . Ops.sourceUnfoldrM)
51+ , benchSrcIO asyncly "unfoldrM/20,000,000"
52+ (avgRate 20000000 . Ops.sourceUnfoldrM)
53+ ]
54+ , bgroup "aheadly"
55+ [
56+ benchSrcIO aheadly "unfoldrM/1,000,000"
57+ (avgRate 1000000 . Ops.sourceUnfoldrM)
58+ ]
59+ ]
60+ ]
streamly.cabal+27
@@ -351,6 +351,33 @@ benchmark linear-async
351 , random >= 1.0 && < 2.0
351 , random >= 1.0 && < 2.0
352 , gauge >= 0.2.3 && < 0.3
352 , gauge >= 0.2.3 && < 0.3
353
353
354+benchmark linear-rate
355+ type: exitcode-stdio-1.0
356+ hs-source-dirs: benchmark
357+ main-is: LinearRate.hs
358+ other-modules: LinearOps
359+ default-language: Haskell2010
360+ ghc-options: -O2 -Wall
361+ if flag(dev)
362+ ghc-options: -Wmissed-specialisations
363+ -Wall-missed-specialisations
364+ -fno-ignore-asserts
365+ if impl(ghc >= 8.0)
366+ ghc-options: -Wcompat
367+ -Wunrecognised-warning-flags
368+ -Widentities
369+ -Wincomplete-record-updates
370+ -Wincomplete-uni-patterns
371+ -Wredundant-constraints
372+ -Wnoncanonical-monad-instances
373+ -Wnoncanonical-monadfail-instances
374+ build-depends:
375+ streamly
376+ , base >= 4.8 && < 5
377+ , deepseq >= 1.4.0 && < 1.5
378+ , random >= 1.0 && < 2.0
379+ , gauge >= 0.2.3 && < 0.3
380+
354benchmark nested
381benchmark nested
355 type: exitcode-stdio-1.0
382 type: exitcode-stdio-1.0
356 hs-source-dirs: benchmark
383 hs-source-dirs: benchmark