on master help sign in
format some parts of the benchmarking code
commite76546fbb1d12171728a37e16dae3f8624d3f8e9 authorHarendra Kumar <harendra@composewell.com> dateFri 28 Feb 2020, 19:44 (7 years ago) parent1f502b1
9 files changed+76−91
benchmark/LinearAsync.hs+9−12 benchmark/LinearRate.hs+9−8 benchmark/Parallel.hs+12−8 benchmark/Streamly/Benchmark/Prelude/Serial/O_1_Space.hs+13−7 benchmark/Streamly/Benchmark/Prelude/Serial/O_n_Heap.hs+9−6 benchmark/Streamly/Benchmark/Prelude/Serial/O_n_Space.hs+13−13 benchmark/Streamly/Benchmark/Prelude/Serial/O_n_Stack.hs+6−7 benchmark/lib/Streamly/Benchmark/Prelude.hs+5−28 benchmark/streamly-benchmarks.cabal−2
benchmark/LinearAsync.hs+9−12
@@ -13,19 +13,15 @@ import Gauge
1313main :: IO ()
1414main = do
1515 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
16− -- let value2 = round $ sqrt $ (fromIntegral value :: Double)
17− value `seq`
18− runMode
19− (mode cfg)
20− cfg
21− benches
22− (concat
23− [ async value
24− , wAsync value
25− , ahead value
26− , o_1_space_async_zip value
27− ])
16+ value `seq` runMode (mode cfg) cfg benches (allBenchmarks value)
2817 where
18+ allBenchmarks value =
19+ concat
20+ [ async value
21+ , wAsync value
22+ , ahead value
23+ , zipAsync value
24+ ]
2925 async value =
3026 concat
3127 [ o_1_space_async_generation value
@@ -47,3 +43,4 @@ main = do
4743 , o_1_space_ahead_concatMap value
4844 , o_1_space_ahead_transformation value
4945 ]
46+ zipAsync = o_1_space_async_zip
benchmark/LinearRate.hs+9−8
@@ -13,11 +13,12 @@ import Gauge
1313main :: IO ()
1414main = do
1515 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
16− value `seq`
17− runMode
18− (mode cfg)
19− cfg
20− benches
21− -- XXX arbitrarily large rate should be the same as rate Nothing
22− (concat
23− [o_1_space_async_avgRate value, o_1_space_ahead_avgRate value])
16+ value `seq` runMode (mode cfg) cfg benches (allBenchmarks value)
17+
18+ where
19+
20+ allBenchmarks value =
21+ concat
22+ [ o_1_space_async_avgRate value
23+ , o_1_space_ahead_avgRate value
24+ ]
benchmark/Parallel.hs+12−8
@@ -13,14 +13,16 @@ import Gauge
1313main :: IO ()
1414main = do
1515 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
16− -- let value2 = round $ sqrt $ (fromIntegral value :: Double)
17− value `seq`
18− runMode
19− (mode cfg)
20− cfg
21− benches
22− (concat [linear value, o_1_space_parallel_outerProductStreams value])
23− where
16+ value `seq` runMode (mode cfg) cfg benches (allBenchmarks value)
17+
18+ where
19+
20+ allBenchmarks value =
21+ concat
22+ [ linear value
23+ , nested value
24+ ]
25+
2426 linear value =
2527 concat
2628 [ o_1_space_parallel_generation value
@@ -29,3 +31,5 @@ main = do
2931 , o_1_space_parallel_concatMap value
3032 , o_1_space_parallel_transformation value
3133 ]
34+
35+ nested = o_1_space_parallel_outerProductStreams
benchmark/Streamly/Benchmark/Prelude/Serial/O_1_Space.hs+13−7
@@ -16,13 +16,17 @@ import Gauge
1616main :: IO ()
1717main = do
1818 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
19− value `seq`
20− runMode
21− (mode cfg)
22− cfg
23− benches
24− (concat [serial value, wSerial value, zipSerial value])
25− where
19+ value `seq` runMode (mode cfg) cfg benches (allBenchmarks value)
20+
21+ where
22+
23+ allBenchmarks value =
24+ concat
25+ [ serial value
26+ , wSerial value
27+ , zipSerial value
28+ ]
29+
2630 serial value =
2731 concat
2832 [ o_1_space_serial_pure value
@@ -48,10 +52,12 @@ main = do
4852 , o_1_space_serial_mixed value
4953 , o_1_space_serial_mixedX4 value
5054 ]
55+
5156 wSerial value =
5257 concat
5358 [ o_1_space_wSerial_transformation value
5459 , o_1_space_wSerial_concatMap value
5560 , o_1_space_wSerial_outerProduct value
5661 ]
62+
5763 zipSerial value = concat [o_1_space_zipSerial_transformation value]
benchmark/Streamly/Benchmark/Prelude/Serial/O_n_Heap.hs+9−6
@@ -17,11 +17,14 @@ main :: IO ()
1717main = do
1818 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
1919 size <- limitStreamSize value
20− size `seq`
21− runMode
22− (mode cfg)
23− cfg
24− benches
20+ size `seq` runMode (mode cfg) cfg benches (allBenchmarks size)
21+
22+ where
23+
2524 -- Operations using O(1) stack space and O(n) heap space.
2625 -- Tail recursive left folds
27− (concat [o_n_heap_serial_foldl size, o_n_heap_serial_buffering size])
26+ allBenchmarks size =
27+ concat
28+ [ o_n_heap_serial_foldl size
29+ , o_n_heap_serial_buffering size
30+ ]
benchmark/Streamly/Benchmark/Prelude/Serial/O_n_Space.hs+13−13
@@ -17,16 +17,16 @@ main :: IO ()
1717main = do
1818 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
1919 size <- limitStreamSize value
20− size `seq`
21− runMode
22− (mode cfg)
23− cfg
24− benches
25− (concat
26− [ o_n_space_serial_toList size -- < 2MB
27− , o_n_space_serial_outerProductStreams size
28− , o_n_space_serial_outerProductUnfolds size
29− , o_n_space_wSerial_outerProductStreams size
30− , o_n_space_serial_traversable size -- < 2MB
31− , o_n_space_serial_foldr size
32− ])
20+ size `seq` runMode (mode cfg) cfg benches (allBenchmarks size)
21+
22+ where
23+
24+ allBenchmarks size =
25+ concat
26+ [ o_n_space_serial_toList size -- < 2MB
27+ , o_n_space_serial_outerProductStreams size
28+ , o_n_space_serial_outerProductUnfolds size
29+ , o_n_space_wSerial_outerProductStreams size
30+ , o_n_space_serial_traversable size -- < 2MB
31+ , o_n_space_serial_foldr size
32+ ]
benchmark/Streamly/Benchmark/Prelude/Serial/O_n_Stack.hs+6−7
@@ -17,11 +17,10 @@ main :: IO ()
1717main = do
1818 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
1919 size <- limitStreamSize value
20+ size `seq` runMode (mode cfg) cfg benches (allBenchmarks size)
21+
22+ where
23+
2024 -- Operations using O(n) stack space but O(1) heap space.
21− size `seq`
22− runMode
23− (mode cfg)
24− cfg
25− benches
26− -- Head recursive operations.
27− (o_n_stack_serial_iterated size)
25+ -- Head recursive operations.
26+ allBenchmarks = o_n_stack_serial_iterated
benchmark/lib/Streamly/Benchmark/Prelude.hs+5−28
@@ -22,6 +22,7 @@
2222#endif
2323
2424module Streamly.Benchmark.Prelude
25+ -- TODO: export a single bench group for o_1_space_serial
2526 ( o_1_space_serial_pure
2627 , o_1_space_serial_foldable
2728 , o_1_space_serial_generation
@@ -82,6 +83,7 @@ module Streamly.Benchmark.Prelude
8283
8384 , o_1_space_async_zip
8485
86+ -- TODO: rename to o_n_*
8587 , o_1_space_parallel_generation
8688 , o_1_space_parallel_concatFoldable
8789 , o_1_space_parallel_concatMap
@@ -119,25 +121,7 @@ import Test.Inspection
119121import qualified Streamly.Internal.Data.Stream.StreamD as D
120122#endif
121123
122−import Streamly
123− ( IsStream
124− , SerialT
125− , aheadly
126− , asyncly
127− , serially
128− , parallely
129− , wAsyncly
130− , wSerially
131− , zipSerially
132− , ahead
133− , async
134− , wAsync
135− , parallel
136− , maxBuffer
137− , maxThreads
138− )
139−
140−import qualified Streamly as S hiding (runStream)
124+import qualified Streamly as S hiding (runStream)
141125import qualified Streamly.Prelude as S
142126import qualified Streamly.Internal.Prelude as Internal
143127import qualified Streamly.Internal.Data.Fold as FL
@@ -157,9 +141,9 @@ import qualified NestedOps as Nested
157141import qualified NestedUnfoldOps as NestedUnfold
158142
159143import Gauge
144+import Streamly hiding (runStream)
160145import Streamly.Benchmark.Common
161146
162−
163147type Stream m a = S.SerialT m a
164148
165149-------------------------------------------------------------------------------
@@ -1894,7 +1878,6 @@ o_1_space_serial_filteringX4 value =
18941878 ]
18951879 ]
18961880
1897−
18981881o_1_space_serial_joining :: Int -> [Benchmark]
18991882o_1_space_serial_joining value =
19001883 [ bgroup
@@ -1915,7 +1898,6 @@ o_1_space_serial_joining value =
19151898 ]
19161899 ]
19171900
1918−
19191901o_1_space_serial_concatFoldable :: Int -> [Benchmark]
19201902o_1_space_serial_concatFoldable value =
19211903 [ bgroup
@@ -1973,7 +1955,6 @@ o_1_space_serial_concatSerial value =
19731955 ]
19741956 ]
19751957
1976−
19771958o_1_space_serial_outerProductStreams :: Int -> [Benchmark]
19781959o_1_space_serial_outerProductStreams value =
19791960 [ bgroup
@@ -1992,7 +1973,6 @@ o_1_space_serial_outerProductStreams value =
19921973 ]
19931974 ]
19941975
1995−
19961976o_1_space_serial_outerProductUnfolds :: Int -> [Benchmark]
19971977o_1_space_serial_outerProductUnfolds value =
19981978 [ bgroup
@@ -2010,7 +1990,6 @@ o_1_space_serial_outerProductUnfolds value =
20101990 ]
20111991 ]
20121992
2013−
20141993o_1_space_serial_mixed :: Int -> [Benchmark]
20151994o_1_space_serial_mixed value =
20161995 [ bgroup
@@ -2335,7 +2314,6 @@ o_1_space_async_concatFoldable value =
23352314 ]
23362315 ]
23372316
2338−
23392317o_1_space_async_concatMap :: Int -> [Benchmark]
23402318o_1_space_async_concatMap value =
23412319 value2 `seq`
@@ -2358,7 +2336,6 @@ o_1_space_async_concatMap value =
23582336 where
23592337 value2 = round $ sqrt $ (fromIntegral value :: Double)
23602338
2361−
23622339o_1_space_async_transformation :: Int -> [Benchmark]
23632340o_1_space_async_transformation value =
23642341 [ bgroup
@@ -2437,7 +2414,6 @@ o_1_space_wAsync_concatMap value =
24372414 where
24382415 value2 = round $ sqrt $ (fromIntegral value :: Double)
24392416
2440−
24412417o_1_space_wAsync_transformation :: Int -> [Benchmark]
24422418o_1_space_wAsync_transformation value =
24432419 [ bgroup
@@ -2659,6 +2635,7 @@ o_n_space_parallel_outerProductStreams value =
26592635 ]
26602636 ]
26612637
2638+-- XXX arbitrarily large rate should be the same as rate Nothing
26622639o_1_space_async_avgRate :: Int -> [Benchmark]
26632640o_1_space_async_avgRate value =
26642641 [ bgroup
benchmark/streamly-benchmarks.cabal−2
@@ -183,7 +183,6 @@ benchmark linear
183183 ghc-options: -with-rtsopts "-T -K36K -M16M"
184184 hs-source-dirs: ., Streamly/Benchmark/Prelude/Serial
185185 main-is: O_1_Space.hs
186− other-modules: NestedOps, NestedUnfoldOps
187186 if impl(ghcjs)
188187 buildable: False
189188 else
@@ -220,7 +219,6 @@ benchmark serial-o-n-space
220219 ghc-options: -with-rtsopts "-T -K16M -M64M"
221220 hs-source-dirs: ., Streamly/Benchmark/Prelude/Serial
222221 main-is: O_n_Space.hs
223− other-modules: NestedOps, NestedUnfoldOps
224222 if impl(ghcjs)
225223 buildable: False
226224 else