on master help sign in
separate the rate benchmarks

rate benchmarks require longer time to run to provide stable results

commitacbfca3502a69973b69ac9a024f37913c78ee3d5 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 11 Oct 2018, 07:08 (8 years ago) parentbdd8a4d
5 files changed+98−25
bench.sh+1−1 benchmark/Chart.hs+10−1 benchmark/LinearAsync.hs−23 benchmark/LinearRate.hs+60 streamly.cabal+27
bench.sh+1−1
@@ -3,7 +3,7 @@
33print_help () {
44 echo "Usage: $0 "
55 echo " [--compare] [--base commit] [--candidate commit]"
6− echo " [--benchmark <linear|nested|base>]"
6+ echo " [--benchmark <linear|linear-async|linear-rate|nested|base>]"
77 echo " [--graphs]"
88 echo " [--slow]"
99 echo " [--no-measure]"
benchmark/Chart.hs+10−1
@@ -20,7 +20,7 @@ import BenchGraph
2020-- Command line parsing
2121------------------------------------------------------------------------------
2222
23−data BenchType = Linear | LinearAsync | Nested | Base
23+data BenchType = Linear | LinearAsync | LinearRate | Nested | Base
2424
2525data Options = Options
2626 { genGraphs :: Bool
@@ -51,6 +51,7 @@ parseBench = do
5151 case x of
5252 Just "linear" -> setBenchType Linear
5353 Just "linear-async" -> setBenchType LinearAsync
54+ Just "linear-rate" -> setBenchType LinearRate
5455 Just "nested" -> setBenchType Nested
5556 Just "base" -> setBenchType Base
5657 Just str -> do
@@ -138,6 +139,11 @@ makeLinearAsyncGraphs cfg inputFile = do
138139 putStrLn "Not implemented"
139140 return ()
140141
142+makeLinearRateGraphs :: Config -> String -> IO ()
143+makeLinearRateGraphs cfg inputFile = do
144+ putStrLn "Not implemented"
145+ return ()
146+
141147------------------------------------------------------------------------------
142148-- Charts for base streams
143149------------------------------------------------------------------------------
@@ -183,6 +189,9 @@ main = do
183189 LinearAsync -> benchShow opts cfg makeLinearAsyncGraphs
184190 "charts/linear-async/results.csv"
185191 "charts/linear-async"
192+ LinearRate -> benchShow opts cfg makeLinearRateGraphs
193+ "charts/linear-rate/results.csv"
194+ "charts/linear-rate"
186195 Nested -> benchShow opts cfg makeNestedGraphs
187196 "charts/nested/results.csv"
188197 "charts/nested"
benchmark/LinearAsync.hs−23
@@ -52,23 +52,6 @@ main = do
5252 , benchSrcIO asyncly "unfoldrM maxBuffer 1 (1000 ops)"
5353 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
5454 ]
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− ]
7255 , bgroup "wAsyncly"
7356 [ -- benchIO "unfoldr" $ Ops.toNull wAsyncly
7457 benchSrcIO wAsyncly "unfoldrM" Ops.sourceUnfoldrM
@@ -93,12 +76,6 @@ main = do
9376 (maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
9477 -- , benchSrcIO aheadly "fromFoldable" Ops.sourceFromFoldable
9578 ]
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− ]
10279 -- XXX need to use smaller streams to finish in reasonable time
10380 , bgroup "parallely"
10481 [ --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
351351 , random >= 1.0 && < 2.0
352352 , gauge >= 0.2.3 && < 0.3
353353
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+
354381benchmark nested
355382 type: exitcode-stdio-1.0
356383 hs-source-dirs: benchmark