on master help sign in
modularize benchmark charting code, use newer bench-graph
54bb7eaHarendra Kumar
bench.sh+216−101
@@ -2,16 +2,20 @@
2
2
3print_help () {
3print_help () {
4 echo "Usage: $0 "
4 echo "Usage: $0 "
5− echo " [--quick] [--append] "
6− echo " [--no-graphs] [--no-measure]"
7− echo " [--benchmark <linear|nested>]"
8 echo " [--compare] [--base commit] [--candidate commit]"
5 echo " [--compare] [--base commit] [--candidate commit]"
6+ echo " [--benchmark <linear|nested|base>]"
7+ echo " [--graphs]"
8+ echo " [--slow]"
9+ echo " [--no-measure]"
10+ echo " [--append] "
9 echo " -- <gauge options>"
11 echo " -- <gauge options>"
10 echo
12 echo
13+ # XXX in the report the base and candidate are shown in reverse order as we
14+ # run the benchmarks for candidate first and then base.
11− echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
15+ #echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
12− echo "commit is generated, in the 'charts' directory."
16+ #echo "commit is generated, in the 'charts' directory."
13− echo "Use --base and --candidate to select the commits to compare."
17+ #echo "Use --base and --candidate to select the commits to compare."
14− echo
18+ #echo
15 echo "Any arguments after a '--' are passed directly to guage"
19 echo "Any arguments after a '--' are passed directly to guage"
16 echo "You can omit '--' if the gauge args used do not start with a '-'."
20 echo "You can omit '--' if the gauge args used do not start with a '-'."
17 exit
21 exit
@@ -23,61 +27,64 @@ die () {
23 exit 1
27 exit 1
24}
28}
25
29
26−DEFAULT_BENCHMARK=linear
30+set_benchmarks() {
27−COMPARE=0
31+ if test -z "$BENCHMARKS"
28−
32+ then
29−while test -n "$1"
33+ BENCHMARKS=$DEFAULT_BENCHMARKS
30−do
34+ echo "Using default benchmark suite [$BENCHMARKS], use --benchmark to specify another"
31− case $1 in
35+ else
32− -h|--help|help) print_help ;;
36+ echo "Using benchmark suite [$BENCHMARKS]"
33− --quick) QUICK=1; shift ;;
37+ fi
34− --append) APPEND=1; shift ;;
38+}
35− --benchmark) shift; BENCHMARK=$1; shift ;;
36− --base) shift; BASE=$1; shift ;;
37− --candidate) shift; CANDIDATE=$1; shift ;;
38− --compare) COMPARE=1; shift ;;
39− --no-graphs) GRAPH=0; shift ;;
40− --no-measure) MEASURE=0; shift ;;
41− --) shift; break ;;
42− -*|--*) print_help ;;
43− *) break ;;
44− esac
45−done
46
39
47−GAUGE_ARGS=$*
40+# $1: benchmark name (linear, nested, base)
41+find_report_prog() {
42+ local bench_name=$1
43+ local prog_name="chart-$bench_name"
44+ hash -r
45+ local prog_path=$($STACK exec which $prog_name)
46+ if test -x "$prog_path"
47+ then
48+ echo $prog_path
49+ else
50+ return 1
51+ fi
52+}
48
53
49−if test -z "$BENCHMARK"
54+# $1: benchmark name (linear, nested, base)
50−then
55+build_report_prog() {
51− BENCHMARK=$DEFAULT_BENCHMARK
56+ local bench_name=$1
52− echo "Using default benchmark suite [$BENCHMARK], use --benchmark to specify another"
57+ local prog_name="chart-$bench_name"
53−else
58+ local prog_path=$($STACK exec which $prog_name)
54− echo "Using benchmark suite [$BENCHMARK]"
55−fi
56
59
57−STACK=stack
60+ hash -r
58−echo "Using stack command [$STACK]"
61+ if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
62+ then
63+ echo "Building bench-graph executables"
64+ BUILD_ONCE=1
65+ $STACK build --flag "streamly:dev" || die "build failed"
66+ elif test ! -x "$prog_path"
67+ then
68+ return 1
69+ fi
70+ return 0
71+}
59
72
60−# We build it first at the current commit before checking out any other commit
73+build_report_progs() {
61−# for benchmarking.
74+ local bench_list=$1
62−if test "$GRAPH" != "0"
63−then
64− CHART_PROG="chart-$BENCHMARK"
65− prog=$($STACK exec which $CHART_PROG)
66− hash -r
67− if test ! -x "$prog"
68− then
69− echo "Building charting executable"
70− $STACK build --flag "streamly:dev" || die "build failed"
71− fi
72
75
73− prog=$($STACK exec which $CHART_PROG)
74− if test ! -x "$prog"
76+ if test "$RAW" = "0"
75 then
77 then
76− die "Could not find [$CHART_PROG] executable"
78+ for i in $bench_list
79+ do
80+ build_report_prog $i || exit 1
81+ local prog
82+ prog=$(find_report_prog $i) || \
83+ die "Cannot find bench-graph executable for benchmark $i"
84+ echo "Using bench-graph executable [$prog]"
85+ done
77 fi
86 fi
78− CHART_PROG=$prog
87+}
79− echo "Using chart executable [$CHART_PROG]"
80−fi
81
88
82# We run the benchmarks in isolation in a separate process so that different
89# We run the benchmarks in isolation in a separate process so that different
83# benchmarks do not interfere with other. To enable that we need to pass the
90# benchmarks do not interfere with other. To enable that we need to pass the
@@ -89,16 +96,21 @@ fi
89# find .stack-work/ -type f -name "benchmarks"
96# find .stack-work/ -type f -name "benchmarks"
90
97
91find_bench_prog () {
98find_bench_prog () {
99+ local bench_name=$1
92− BENCH_PROG=`$STACK path --dist-dir`/build/$BENCHMARK/$BENCHMARK
100+ local bench_prog=`$STACK path --dist-dir`/build/$bench_name/$bench_name
93− if test ! -x "$BENCH_PROG"
101+ if test -x "$bench_prog"
94 then
102 then
95− echo
103+ echo $bench_prog
96− echo "WARNING! benchmark binary [$BENCH_PROG] not found or not executable"
104+ else
97− echo "WARNING! not using isolated measurement."
105+ return 1
98− echo
99 fi
106 fi
100}
107}
101
108
109+bench_output_file() {
110+ local bench_name=$1
111+ echo "charts/$bench_name/results.csv"
112+}
113+
102# --min-duration 0 means exactly one iteration per sample. We use a million
114# --min-duration 0 means exactly one iteration per sample. We use a million
103# iterations in the benchmarking code explicitly and do not use the iterations
115# iterations in the benchmarking code explicitly and do not use the iterations
104# done by the benchmarking tool.
116# done by the benchmarking tool.
@@ -112,44 +124,33 @@ find_bench_prog () {
112# We can pass --min-samples value from the command line as second argument
124# We can pass --min-samples value from the command line as second argument
113# after the benchmark name in case we want to use more than one sample.
125# after the benchmark name in case we want to use more than one sample.
114
126
115−if test "$QUICK" = "1"
127+run_bench () {
116−then
128+ local bench_name=$1
117− ENABLE_QUICK="--quick"
129+ local output_file=$(bench_output_file $bench_name)
118−fi
130+ local bench_prog
131+ bench_prog=$(find_bench_prog $bench_name) || \
132+ die "Cannot find benchmark executable for benchmark $bench_name"
119
133
120−OUTPUT_FILE="charts/results.csv"
134+ mkdir -p `dirname $output_file`
121
135
122−run_bench () {
136+ echo "Running benchmark $bench_name ..."
123− $STACK build --bench --no-run-benchmarks || die "build failed"
137+
124− find_bench_prog
138+ $bench_prog $SPEED_OPTIONS \
125− mkdir -p charts
139+ --csvraw=$output_file \
126−
127− # We set min-samples to 3 if we use less than three samples, statistical
128− # analysis crashes. Note that the benchmark runs for a minimum of 5 seconds.
129− # We use min-duration=0 to run just one iteration for each sample. Anyway the
130− # default is to run iterations worth minimum 30 ms and most of our benchmarks
131− # are close to that or more.
132− $BENCH_PROG $ENABLE_QUICK \
133− --include-first-iter \
134− --min-samples 3 \
135− --min-duration 0 \
136− --match exact \
137− --csvraw=$OUTPUT_FILE \
138 -v 2 \
140 -v 2 \
139− --measure-with $BENCH_PROG $GAUGE_ARGS || die "Benchmarking failed"
141+ --measure-with $bench_prog $GAUGE_ARGS || die "Benchmarking failed"
140}
142}
141
143
142−if test "$MEASURE" != "0"
144+run_benches() {
143− then
145+ for i in $1
144− if test -e $OUTPUT_FILE -a "$APPEND" != 1
146+ do
145− then
147+ run_bench $i
146− mv -f -v $OUTPUT_FILE ${OUTPUT_FILE}.prev
148+ done
147− fi
149+}
150+
151+run_benches_comparing() {
152+ local bench_list=$1
148
153
149− if test "$COMPARE" = "0"
150− then
151− run_bench
152− else
153 if test -z "$CANDIDATE"
154 if test -z "$CANDIDATE"
154 then
155 then
155 CANDIDATE=$(git rev-parse HEAD)
156 CANDIDATE=$(git rev-parse HEAD)
@@ -161,18 +162,132 @@ if test "$MEASURE" != "0"
161 fi
162 fi
162 echo "Checking out base commit for benchmarking"
163 echo "Checking out base commit for benchmarking"
163 git checkout "$BASE" || die "Checkout of base commit failed"
164 git checkout "$BASE" || die "Checkout of base commit failed"
164− run_bench
165+
166+ run_benches "$bench_list"
167+
165 echo "Checking out candidate commit for benchmarking"
168 echo "Checking out candidate commit for benchmarking"
166 git checkout "$CANDIDATE" || die "Checkout of candidate commit failed"
169 git checkout "$CANDIDATE" || die "Checkout of candidate commit failed"
167− run_bench
170+
171+ run_benches "$bench_list"
172+ # XXX reset back to the original commit
173+}
174+
175+backup_output_file() {
176+ local bench_name=$1
177+ local output_file=$(bench_output_file $bench_name)
178+
179+ if test -e $output_file -a "$APPEND" != 1
180+ then
181+ mv -f -v $output_file ${output_file}.prev
168 fi
182 fi
183+}
184+
185+run_measurements() {
186+ local bench_list=$1
187+
188+ for i in $bench_list
189+ do
190+ backup_output_file $i
191+ done
192+
193+ if test "$COMPARE" = "0"
194+ then
195+ run_benches "$bench_list"
196+ else
197+ run_benches_comparing "$bench_list"
169−fi
198+ fi
199+}
200+
201+run_report() {
202+ local bench_name=$1
203+ local input_file=$2
204+
205+ if test "$RAW" = "0"
206+ then
207+ local prog
208+ prog=$(find_report_prog $bench_name) || \
209+ die "Cannot find bench-graph executable for benchmark $bench_name"
210+ echo
211+ echo "Generating reports for ${bench_name}..."
212+ $prog
213+ fi
214+}
215+
216+run_reports() {
217+ for i in $1
218+ do
219+ run_report $i
220+ done
221+}
222+
223+#-----------------------------------------------------------------------------
224+# Execution starts here
225+#-----------------------------------------------------------------------------
226+
227+DEFAULT_BENCHMARKS="linear"
228+
229+COMPARE=0
230+BASE=
231+CANDIDATE=
232+
233+APPEND=0
234+RAW=0
235+GRAPH=0
236+MEASURE=1
237+SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
170
238
171−if test "$GRAPH" != "0"
239+STACK=stack
240+GAUGE_ARGS=
241+
242+BUILD_ONCE=0
243+
244+#-----------------------------------------------------------------------------
245+# Read command line
246+#-----------------------------------------------------------------------------
247+
248+while test -n "$1"
249+do
250+ case $1 in
251+ -h|--help|help) print_help ;;
252+ --slow) SPEED_OPTIONS="--min-duration 0"; shift ;;
253+ --append) APPEND=1; shift ;;
254+ --benchmark) shift; BENCHMARKS=$1; shift ;;
255+ --base) shift; BASE=$1; shift ;;
256+ --candidate) shift; CANDIDATE=$1; shift ;;
257+ --compare) COMPARE=1; shift ;;
258+ --raw) RAW=1; shift ;;
259+ --graphs) GRAPH=1; shift ;;
260+ --no-measure) MEASURE=0; shift ;;
261+ --) shift; break ;;
262+ -*|--*) print_help ;;
263+ *) break ;;
264+ esac
265+done
266+GAUGE_ARGS=$*
267+
268+echo "Using stack command [$STACK]"
269+set_benchmarks
270+
271+#-----------------------------------------------------------------------------
272+# Build stuff
273+#-----------------------------------------------------------------------------
274+
275+# We need to build the report progs first at the current (latest) commit before
276+# checking out any other commit for benchmarking.
277+build_report_progs "$BENCHMARKS"
278+
279+#-----------------------------------------------------------------------------
280+# Run benchmarks
281+#-----------------------------------------------------------------------------
282+
283+if test "$MEASURE" = "1"
172then
284then
173− echo
285+ $STACK build --bench --no-run-benchmarks || die "build failed"
174− echo "Generating charts from ${OUTPUT_FILE}..."
286+ run_measurements "$BENCHMARKS"
175− $CHART_PROG
176fi
287fi
177
288
178−# XXX reset back to the original commit
289+#-----------------------------------------------------------------------------
290+# Run reports
291+#-----------------------------------------------------------------------------
292+
293+run_reports "$BENCHMARKS"
benchmark/ChartLinear.hs+60−24
@@ -1,30 +1,28 @@
1{-# LANGUAGE TupleSections #-}
1{-# LANGUAGE TupleSections #-}
2+{-# LANGUAGE RecordWildCards #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3
4
4module Main where
5module Main where
5
6
7+import Control.Exception (handle, catch, SomeException, ErrorCall(..))
8+import Control.Monad.Trans.State
9+import Control.Monad.Trans.Maybe
6import Data.List
10import Data.List
7import Data.List.Split
11import Data.List.Split
8−import BenchGraph (bgraph, defaultConfig, Config(..), ComparisonStyle(..))
12+import Data.Ord (comparing)
9−import Control.Exception (handle, catch, SomeException, ErrorCall(..))
13+import System.Environment (getArgs)
14+import Control.Monad.IO.Class (liftIO)
15+import Control.Monad (mzero)
10
16
11−main :: IO ()
17+import BenchGraph
12−main = do
18+import Utils
13− let cfg = defaultConfig
14− { outputDir = "charts"
15− , comparisonStyle = CompareDelta
16− }
17
19
18− ignoringErr a = catch a (\(ErrorCall err :: ErrorCall) ->
20+ignoringErr a = catch a (\(ErrorCall err :: ErrorCall) ->
19− putStrLn $ "Failed with error:\n" ++ err ++ "\nSkipping.")
21+ putStrLn $ "Failed with error:\n" ++ err ++ "\nSkipping.")
20− -- bgraph <input> <output> <field in csv file to be plotted>
22+
21− -- other interesting fields to plot are:
23+makeGraphs cfg = do
22− -- allocated
23− -- bytesCopied
24− -- mutatorCpuSeconds
25− -- gcCpuSeconds
26− ignoringErr $ bgraph "charts/results.csv" "operations" "time" $ cfg
24+ ignoringErr $ graph inputFile "operations" $ cfg
27− { chartTitle = Just "Streamly operations (time)"
25+ { title = Just "Streamly operations"
28 , classifyBenchmark = \b ->
26 , classifyBenchmark = \b ->
29 if (not $ "serially/" `isPrefixOf` b)
27 if (not $ "serially/" `isPrefixOf` b)
30 || "/generation" `isInfixOf` b
28 || "/generation" `isInfixOf` b
@@ -34,21 +32,59 @@ main = do
34 else Just ("Streamly", last $ splitOn "/" b)
32 else Just ("Streamly", last $ splitOn "/" b)
35 }
33 }
36
34
37− ignoringErr $ bgraph "charts/results.csv" "generation" "time" $ cfg
35+ ignoringErr $ graph inputFile "generation" $ cfg
38− { chartTitle = Just "Stream generation (time)"
36+ { title = Just "Stream generation"
39 , classifyBenchmark = \b ->
37 , classifyBenchmark = \b ->
40 if "serially/generation" `isPrefixOf` b
38 if "serially/generation" `isPrefixOf` b
41 then Just ("Streamly", last $ splitOn "/" b)
39 then Just ("Streamly", last $ splitOn "/" b)
42 else Nothing
40 else Nothing
43 }
41 }
44
42
45− ignoringErr $ bgraph "charts/results.csv" "composition" "time" $ cfg
43+ ignoringErr $ graph inputFile "composition" $ cfg
46− { chartTitle = Just "Streamly composition performance (time)"
44+ { title = Just "Streamly composition performance"
47 , classifyBenchmark = fmap ("Streamly",) . stripPrefix "serially/compose/"
45 , classifyBenchmark = fmap ("Streamly",) . stripPrefix "serially/compose/"
48 }
46 }
49
47
50− ignoringErr $ bgraph "charts/results.csv" "composition-scaling" "time"
48+ ignoringErr $ graph inputFile "composition-scaling"
51 $ cfg
49 $ cfg
52− { chartTitle = Just "Streamly composition scaling (time)"
50+ { title = Just "Streamly composition scaling"
53 , classifyBenchmark = fmap ("Streamly",) . stripPrefix "serially/compose-"
51 , classifyBenchmark = fmap ("Streamly",) . stripPrefix "serially/compose-"
54 }
52 }
53+
54+inputFile :: String
55+inputFile = "charts/linear/results.csv"
56+
57+-- Primitive command line options parsing
58+data Options = Options
59+ { genGraphs :: Bool
60+ }
61+
62+main :: IO ()
63+main = do
64+ let cfg = defaultConfig
65+ { outputDir = Just "charts/linear"
66+ , presentation = Groups PercentDiff
67+ }
68+
69+ args <- getArgs
70+ res <- runMaybeT $ flip evalStateT args $ do
71+ x <- shift
72+ case x of
73+ Just "--graphs" -> return $ Options { genGraphs = True }
74+ Nothing -> return $ Options { genGraphs = False }
75+ Just str -> do
76+ liftIO $ putStrLn $ "Unrecognized option " ++ str
77+ mzero
78+
79+ case res of
80+ Nothing -> return ()
81+ Just Options{..} ->
82+ if genGraphs
83+ then makeGraphs cfg
84+ else
85+ ignoringErr $ report inputFile Nothing $ cfg
86+ { selectBenchmarks =
87+ \f ->
88+ reverse $ map fst $
89+ sortBy (comparing snd) $ f $ ColumnIndex 1
90+ }
benchmark/ChartNested.hs+54−30
@@ -1,46 +1,70 @@
1{-# LANGUAGE TupleSections #-}
1{-# LANGUAGE TupleSections #-}
2+{-# LANGUAGE RecordWildCards #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3
4
4module Main where
5module Main where
5
6
7+import Control.Exception (handle, catch, SomeException, ErrorCall)
8+import Control.Monad.Trans.State
9+import Control.Monad.Trans.Maybe
6import Data.List
10import Data.List
7import Data.List.Split
11import Data.List.Split
8−import BenchGraph (bgraph, defaultConfig, Config(..), ComparisonStyle(..))
12+import Data.Ord (comparing)
9−import Control.Exception (handle, catch, SomeException, ErrorCall)
13+import System.Environment (getArgs)
14+import Control.Monad.IO.Class (liftIO)
15+import Control.Monad (mzero)
10
16
11−main :: IO ()
17+import BenchGraph
12−main = do
18+import Utils
13− let cfg = defaultConfig
14− { outputDir = "charts"
15− , comparisonStyle = CompareFull
16− }
17
19
18− ignoringErr a = catch a (\(_ :: ErrorCall) ->
20+ignoringErr a = catch a (\(_ :: ErrorCall) ->
19− putStrLn "Failed. Skipping.")
21+ putStrLn "Failed. Skipping.")
20− -- bgraph <input> <output> <field in csv file to be plotted>
21− -- other interesting fields to plot are:
22− -- allocated
23− -- bytesCopied
24− -- mutatorCpuSeconds
25− -- gcCpuSeconds
26− ignoringErr $ bgraph "charts/results.csv" "nested-ops" "time" $ cfg
27− { chartTitle = Just "Nested operations (time)"
28− , classifyBenchmark = \b ->
29− let ls = splitOn "/" b
30− in case head ls of
31− "linear" -> Nothing
32− _ -> Just (head ls, last ls)
33− , sortBenchmarks = nub
34− , comparisonStyle = CompareFull
35− }
36
22
23+makeGraphs :: Config -> IO ()
24+makeGraphs cfg = do
37− ignoringErr $ bgraph "charts/results.csv" "nested-serial-comparative" "time" $ cfg
25+ ignoringErr $ graph inputFile "nested-serial-diff" $ cfg
38− { chartTitle = Just "Nested serial diff (time)"
26+ { title = Just "Nested serial"
39 , classifyBenchmark = \b ->
27 , classifyBenchmark = \b ->
40 let ls = splitOn "/" b
28 let ls = splitOn "/" b
41 in case head ls of
29 in case head ls of
42 "serially" -> Just (head ls, last ls)
30 "serially" -> Just (head ls, last ls)
43 _ -> Nothing
31 _ -> Nothing
44− , sortBenchmarks = nub
45− , comparisonStyle = CompareDelta
46 }
32 }
33+
34+-- Primitive command line options parsing
35+data Options = Options
36+ { genGraphs :: Bool
37+ }
38+
39+inputFile :: String
40+inputFile = "charts/nested/results.csv"
41+
42+main :: IO ()
43+main = do
44+ let cfg = defaultConfig
45+ { outputDir = Just "charts/nested"
46+ , presentation = Groups PercentDiff
47+ }
48+
49+ args <- getArgs
50+ res <- runMaybeT $ flip evalStateT args $ do
51+ x <- shift
52+ case x of
53+ Just "--graphs" -> return $ Options { genGraphs = True }
54+ Nothing -> return $ Options { genGraphs = False }
55+ Just str -> do
56+ liftIO $ putStrLn $ "Unrecognized option " ++ str
57+ mzero
58+
59+ case res of
60+ Nothing -> return ()
61+ Just Options{..} ->
62+ if genGraphs
63+ then makeGraphs cfg
64+ else
65+ ignoringErr $ report inputFile Nothing $ cfg
66+ { selectBenchmarks =
67+ \f ->
68+ reverse $ map fst $
69+ sortBy (comparing snd) $ f $ ColumnIndex 1
70+ }
benchmark/Linear.hs+1−1
@@ -94,7 +94,7 @@ main = do
94 (Ops.sequence serially) (Ops.sourceUnfoldrMAction n)
94 (Ops.sequence serially) (Ops.sourceUnfoldrMAction n)
95 , benchIO "findIndices" Ops.findIndices
95 , benchIO "findIndices" Ops.findIndices
96 , benchIO "elemIndices" Ops.elemIndices
96 , benchIO "elemIndices" Ops.elemIndices
97− , benchIO "concat" Ops.concat
97+ -- , benchIO "concat" Ops.concat
98 ]
98 ]
99 , bgroup "filtering"
99 , bgroup "filtering"
100 [ benchIO "filter-even" Ops.filterEven
100 [ benchIO "filter-even" Ops.filterEven
benchmark/Nested.hs+6−7
@@ -25,7 +25,7 @@ main = do
25 [ bgroup "serially"
25 [ bgroup "serially"
26 [ benchIO "toNull" $ Ops.toNull serially
26 [ benchIO "toNull" $ Ops.toNull serially
27 , benchIO "toList" $ Ops.toList serially
27 , benchIO "toList" $ Ops.toList serially
28− , benchIO "toListSome" $ Ops.toListSome serially
28+ -- , benchIO "toListSome" $ Ops.toListSome serially
29 , benchIO "filterAllOut" $ Ops.filterAllOut serially
29 , benchIO "filterAllOut" $ Ops.filterAllOut serially
30 , benchIO "filterAllIn" $ Ops.filterAllIn serially
30 , benchIO "filterAllIn" $ Ops.filterAllIn serially
31 , benchIO "filterSome" $ Ops.filterSome serially
31 , benchIO "filterSome" $ Ops.filterSome serially
@@ -35,7 +35,7 @@ main = do
35 , bgroup "wSerially"
35 , bgroup "wSerially"
36 [ benchIO "toNull" $ Ops.toNull wSerially
36 [ benchIO "toNull" $ Ops.toNull wSerially
37 , benchIO "toList" $ Ops.toList wSerially
37 , benchIO "toList" $ Ops.toList wSerially
38− , benchIO "toListSome" $ Ops.toListSome wSerially
38+ -- , benchIO "toListSome" $ Ops.toListSome wSerially
39 , benchIO "filterAllOut" $ Ops.filterAllOut wSerially
39 , benchIO "filterAllOut" $ Ops.filterAllOut wSerially
40 , benchIO "filterAllIn" $ Ops.filterAllIn wSerially
40 , benchIO "filterAllIn" $ Ops.filterAllIn wSerially
41 , benchIO "filterSome" $ Ops.filterSome wSerially
41 , benchIO "filterSome" $ Ops.filterSome wSerially
@@ -45,10 +45,9 @@ main = do
45 , bgroup "aheadly"
45 , bgroup "aheadly"
46 [ benchIO "toNull" $ Ops.toNull aheadly
46 [ benchIO "toNull" $ Ops.toNull aheadly
47 , benchIO "toList" $ Ops.toList aheadly
47 , benchIO "toList" $ Ops.toList aheadly
48− , benchIO "toListSome" $ Ops.toListSome aheadly
48+ -- , benchIO "toListSome" $ Ops.toListSome aheadly
49 , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
49 , benchIO "filterAllOut" $ Ops.filterAllOut aheadly
50 , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
50 , benchIO "filterAllIn" $ Ops.filterAllIn aheadly
51− -- this hangs, need to investigate
52 , benchIO "filterSome" $ Ops.filterSome aheadly
51 , benchIO "filterSome" $ Ops.filterSome aheadly
53 , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
52 , benchIO "breakAfterSome" $ Ops.breakAfterSome aheadly
54 ]
53 ]
@@ -56,7 +55,7 @@ main = do
56 , bgroup "asyncly"
55 , bgroup "asyncly"
57 [ benchIO "toNull" $ Ops.toNull asyncly
56 [ benchIO "toNull" $ Ops.toNull asyncly
58 , benchIO "toList" $ Ops.toList asyncly
57 , benchIO "toList" $ Ops.toList asyncly
59− , benchIO "toListSome" $ Ops.toListSome asyncly
58+ -- , benchIO "toListSome" $ Ops.toListSome asyncly
60 , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
59 , benchIO "filterAllOut" $ Ops.filterAllOut asyncly
61 , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
60 , benchIO "filterAllIn" $ Ops.filterAllIn asyncly
62 , benchIO "filterSome" $ Ops.filterSome asyncly
61 , benchIO "filterSome" $ Ops.filterSome asyncly
@@ -66,7 +65,7 @@ main = do
66 , bgroup "wAsyncly"
65 , bgroup "wAsyncly"
67 [ benchIO "toNull" $ Ops.toNull wAsyncly
66 [ benchIO "toNull" $ Ops.toNull wAsyncly
68 , benchIO "toList" $ Ops.toList wAsyncly
67 , benchIO "toList" $ Ops.toList wAsyncly
69− , benchIO "toListSome" $ Ops.toListSome wAsyncly
68+ -- , benchIO "toListSome" $ Ops.toListSome wAsyncly
70 , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
69 , benchIO "filterAllOut" $ Ops.filterAllOut wAsyncly
71 , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
70 , benchIO "filterAllIn" $ Ops.filterAllIn wAsyncly
72 , benchIO "filterSome" $ Ops.filterSome wAsyncly
71 , benchIO "filterSome" $ Ops.filterSome wAsyncly
@@ -76,7 +75,7 @@ main = do
76 , bgroup "parallely"
75 , bgroup "parallely"
77 [ benchIO "toNull" $ Ops.toNull parallely
76 [ benchIO "toNull" $ Ops.toNull parallely
78 , benchIO "toList" $ Ops.toList parallely
77 , benchIO "toList" $ Ops.toList parallely
79− , benchIO "toListSome" $ Ops.toListSome parallely
78+ --, benchIO "toListSome" $ Ops.toListSome parallely
80 , benchIO "filterAllOut" $ Ops.filterAllOut parallely
79 , benchIO "filterAllOut" $ Ops.filterAllOut parallely
81 , benchIO "filterAllIn" $ Ops.filterAllIn parallely
80 , benchIO "filterAllIn" $ Ops.filterAllIn parallely
82 , benchIO "filterSome" $ Ops.filterSome parallely
81 , benchIO "filterSome" $ Ops.filterSome parallely
benchmark/NestedOps.hs+1−1
@@ -20,7 +20,7 @@ sumCount :: Int
20sumCount = 1000000
20sumCount = 1000000
21
21
22prodCount :: Int
22prodCount :: Int
23−prodCount = 1000
23+prodCount = 100
24
24
25-------------------------------------------------------------------------------
25-------------------------------------------------------------------------------
26-- Stream generation and elimination
26-- Stream generation and elimination
benchmark/Utils.hsnew file+13
@@ -0,0 +1,13 @@
1+module Utils where
2+
3+import Control.Monad.Trans.State
4+import Control.Monad.Trans.Maybe
5+
6+-- Like the shell "shift" to shift the command line arguments
7+shift :: StateT [String] (MaybeT IO) (Maybe String)
8+shift = do
9+ s <- get
10+ case s of
11+ [] -> return Nothing
12+ x : xs -> put xs >> return (Just x)
13+
stack.yaml+9−2
@@ -1,14 +1,21 @@
1−resolver: lts-12.0
1+resolver: lts-12.11
2packages:
2packages:
3- '.'
3- '.'
4allow-newer: true
4allow-newer: true
5extra-deps:
5extra-deps:
6 - SDL-0.6.6.0
6 - SDL-0.6.6.0
7 - gauge-0.2.3
7 - gauge-0.2.3
8− - bench-graph-0.1.3
8+ #- bench-graph-0.1.4
9 - Chart-1.9
9 - Chart-1.9
10 - Chart-diagrams-1.9
10 - Chart-diagrams-1.9
11 - SVGFonts-1.6.0.3
11 - SVGFonts-1.6.0.3
12+ - math-functions-0.3.0.2
13+ - git: git@github.com:composewell/bench-graph
14+ commit: 27ea72037f01e252364197e4771e25478af97972
15+ - git: git@github.com:harendra-kumar/statistics
16+ commit: d3c4743c28fdd83d578039867f1a046596f77140
17+ subdirs:
18+ - dense-linear-algebra
12
19
13flags: {}
20flags: {}
14extra-package-dbs: []
21extra-package-dbs: []
streamly.cabal+4
@@ -414,12 +414,14 @@ executable chart-linear
414 default-language: Haskell2010
414 default-language: Haskell2010
415 hs-source-dirs: benchmark
415 hs-source-dirs: benchmark
416 main-is: ChartLinear.hs
416 main-is: ChartLinear.hs
417+ other-modules: Utils
417 if flag(dev)
418 if flag(dev)
418 buildable: True
419 buildable: True
419 build-Depends:
420 build-Depends:
420 base >= 4.8 && < 5
421 base >= 4.8 && < 5
421 , bench-graph >= 0.1 && < 0.2
422 , bench-graph >= 0.1 && < 0.2
422 , split
423 , split
424+ , transformers
423 else
425 else
424 buildable: False
426 buildable: False
425
427
@@ -427,12 +429,14 @@ executable chart-nested
427 default-language: Haskell2010
429 default-language: Haskell2010
428 hs-source-dirs: benchmark
430 hs-source-dirs: benchmark
429 main-is: ChartNested.hs
431 main-is: ChartNested.hs
432+ other-modules: Utils
430 if flag(dev)
433 if flag(dev)
431 buildable: True
434 buildable: True
432 build-Depends:
435 build-Depends:
433 base >= 4.8 && < 5
436 base >= 4.8 && < 5
434 , bench-graph >= 0.1 && < 0.2
437 , bench-graph >= 0.1 && < 0.2
435 , split
438 , split
439+ , transformers
436 else
440 else
437 buildable: False
441 buildable: False
438
442