3ALL_BENCHMARKS="linear linear-async linear-rate nested nested-concurrent nested-unfold concurrent fileio array base"
7 echo " [--benchmarks <all|linear|linear-async|linear-rate|nested|nested-concurrent|nested-unfold|concurrent|fileio|array|base>]"
10 echo " [--no-measure]"
15 echo " [--compare] [--base commit] [--candidate commit]"
16 echo " [--cabal-build-flags]"
17 echo " -- <gauge options>"
19 echo "Multiple benchmarks can be specified as a space separate list"
20 echo " e.g. --benchmarks \"linear nested\""
22 echo "--group-diff is used to compare groups within a single benchmark"
23 echo " e.g. StreamD vs StreamK in base benchmark."
25 echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
26 echo "commit is generated, in the 'charts' directory."
27 echo "Use --base and --candidate to select the commits to compare."
29 echo "Any arguments after a '--' are passed directly to gauge"
35 >&2 echo -e "Error: $1"
40 if test -z "$BENCHMARKS"
42 BENCHMARKS=$DEFAULT_BENCHMARKS
43 elif test "$BENCHMARKS" = "all"
45 BENCHMARKS=$ALL_BENCHMARKS
47 echo "Using benchmark suites [$BENCHMARKS]"
50# $1: benchmark name (linear, nested, base)
52 local prog_name="chart"
54 local prog_path=$($WHICH_COMMAND $prog_name)
55 if test -x "$prog_path"
63# $1: benchmark name (linear, nested, base)
65 local prog_name="chart"
66 local prog_path=$($WHICH_COMMAND $prog_name)
69 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
71 echo "Building bench-graph executables"
73 $BUILD_CHART_EXE || die "build failed"
74 elif test ! -x "$prog_path"
84 build_report_prog || exit 1
86 prog=$(find_report_prog) || \
87 die "Cannot find bench-graph executable"
88 echo "Using bench-graph executable [$prog]"
92# We run the benchmarks in isolation in a separate process so that different
93# benchmarks do not interfere with other. To enable that we need to pass the
94# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
97# The path is dependent on the architecture and cabal version.
98# Use this command to find the exe if this script fails with an error:
99# find .stack-work/ -type f -name "benchmarks"
103 local bench_prog=`stack path --dist-dir`/build/$bench_name/$bench_name
104 if test -x "$bench_prog"
114 local bench_prog=`$WHICH_COMMAND $1`
115 if test -x "$bench_prog"
125 echo "charts/$bench_name/results.csv"
128# --min-duration 0 means exactly one iteration per sample. We use a million
129# iterations in the benchmarking code explicitly and do not use the iterations
130# done by the benchmarking tool.
132# Benchmarking tool by default discards the first iteration to remove
133# aberrations due to initial evaluations etc. We do not discard it because we
134# are anyway doing iterations in the benchmarking code and many of them so that
135# any constant factor gets amortized and anyway it is a cost that we pay in
138# We can pass --min-samples value from the command line as second argument
139# after the benchmark name in case we want to use more than one sample.
143 local output_file=$(bench_output_file $bench_name)
145 bench_prog=$($GET_BENCH_PROG $bench_name) || \
146 die "Cannot find benchmark executable for benchmark $bench_name"
148 mkdir -p `dirname $output_file`
150 echo "Running benchmark $bench_name ..."
152 local QUICK_OPTS="--quick --time-limit 1 --min-duration 0"
154 if test "$LONG" -eq 0
156 if test "$SLOW" -eq 0
158 if test "$QUICK" -eq 0
161 SPEED_OPTIONS="$QUICK_OPTS --min-samples 10"
163 # super quick but less accurate
164 SPEED_OPTIONS="$QUICK_OPTS --include-first-iter"
167 SPEED_OPTIONS="--min-duration 0"
170 SPEED_OPTIONS="--stream-size 10000000 $QUICK_OPTS --include-first-iter"
173 $bench_prog $SPEED_OPTIONS \
174 --csvraw=$output_file \
176 --measure-with $bench_prog $GAUGE_ARGS || die "Benchmarking failed"
186run_benches_comparing() {
189 if test -z "$CANDIDATE"
191 CANDIDATE=$(git rev-parse HEAD)
195 # XXX Should be where the current branch is forked from master
198 echo "Comparing baseline commit [$BASE] with candidate [$CANDIDATE]"
199 echo "Checking out base commit [$BASE] for benchmarking"
200 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
202 $BUILD_BENCH || die "build failed"
203 run_benches "$bench_list"
205 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
206 git checkout "$CANDIDATE" || \
207 die "Checkout of candidate [$CANDIDATE] commit failed"
209 $BUILD_BENCH || die "build failed"
210 run_benches "$bench_list"
211 # XXX reset back to the original commit
214backup_output_file() {
216 local output_file=$(bench_output_file $bench_name)
218 if test -e $output_file -a "$APPEND" != 1
220 mv -f -v $output_file ${output_file}.prev
229 backup_output_file $i
232 if test "$COMPARE" = "0"
234 run_benches "$bench_list"
236 run_benches_comparing "$bench_list"
242 prog=$(find_report_prog) || \
243 die "Cannot find bench-graph executable"
248 echo "Generating reports for ${i}..."
249 $prog $(test "$GRAPH" = 1 && echo "--graphs") \
250 $(test "$GROUP_DIFF" = 1 && echo "--group-diff") \
255#-----------------------------------------------------------------------------
256# Execution starts here
257#-----------------------------------------------------------------------------
259DEFAULT_BENCHMARKS="linear"
279GHC_VERSION=$(ghc --numeric-version)
282 find dist-newstyle -type f -path "*${GHC_VERSION}*/$1"
285#-----------------------------------------------------------------------------
287#-----------------------------------------------------------------------------
292 -h|--help|help) print_help ;;
293 # options with arguments
294 --benchmarks) shift; BENCHMARKS=$1; shift ;;
295 --base) shift; BASE=$1; shift ;;
296 --candidate) shift; CANDIDATE=$1; shift ;;
297 --cabal-build-flags) shift; CABAL_BUILD_FLAGS=$1; shift ;;
299 --slow) SLOW=1; shift ;;
300 --quick) QUICK=1; shift ;;
301 --compare) COMPARE=1; shift ;;
302 --raw) RAW=1; shift ;;
303 --append) APPEND=1; shift ;;
304 --long) LONG=1; shift ;;
305 --group-diff) GROUP_DIFF=1; shift ;;
306 --graphs) GRAPH=1; shift ;;
307 --no-measure) MEASURE=0; shift ;;
309 -*|--*) print_help ;;
315echo "Using stack command [$STACK]"
318# XXX we can remove these if we pass stack build flags from command line like
320if echo "$BENCHMARKS" | grep -q base
322 STACK_BUILD_FLAGS="--flag streamly:dev"
327 if test "$i" = concurrent
329 STACK_BUILD_FLAGS="--flag streamly:dev"
334if test "$USE_STACK" = "1"
336 WHICH_COMMAND="stack exec which"
337 BUILD_CHART_EXE="stack build --flag streamly:dev"
338 GET_BENCH_PROG=stack_bench_prog
339 BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
341 # XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
342 #WHICH_COMMAND="cabal v2-exec which"
343 WHICH_COMMAND=cabal_which
344 BUILD_CHART_EXE="cabal v2-build --flags dev chart"
345 GET_BENCH_PROG=cabal_bench_prog
346 BUILD_BENCH="cabal v2-build $CABAL_BUILD_FLAGS --enable-benchmarks"
349#-----------------------------------------------------------------------------
351#-----------------------------------------------------------------------------
353# We need to build the report progs first at the current (latest) commit before
354# checking out any other commit for benchmarking.
355build_report_progs "$BENCHMARKS"
357#-----------------------------------------------------------------------------
359#-----------------------------------------------------------------------------
361if test "$MEASURE" = "1"
364 if test "$USE_STACK" = "1"
366 $BUILD_BENCH || die "build failed"
368 $BUILD_BENCH $BENCHMARKS || die "build failed"
370 run_measurements "$BENCHMARKS"
373#-----------------------------------------------------------------------------
375#-----------------------------------------------------------------------------
379 run_reports "$BENCHMARKS"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list