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]"
13 echo " [--compare] [--base commit] [--candidate commit]"
15 echo " -- <gauge options>"
17 echo "Multiple benchmarks can be specified as a space separate list"
18 echo " e.g. --benchmarks \"linear nested\""
20 echo "--group-diff is used to compare groups within a single benchmark"
21 echo " e.g. StreamD vs StreamK in base benchmark."
23 echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
24 echo "commit is generated, in the 'charts' directory."
25 echo "Use --base and --candidate to select the commits to compare."
27 echo "Any arguments after a '--' are passed directly to gauge"
33 >&2 echo -e "Error: $1"
38 if test -z "$BENCHMARKS"
40 BENCHMARKS=$DEFAULT_BENCHMARKS
41 elif test "$BENCHMARKS" = "all"
43 BENCHMARKS=$ALL_BENCHMARKS
45 echo "Using benchmark suites [$BENCHMARKS]"
48# $1: benchmark name (linear, nested, base)
50 local prog_name="chart"
52 local prog_path=$($WHICH_COMMAND $prog_name)
53 if test -x "$prog_path"
61# $1: benchmark name (linear, nested, base)
63 local prog_name="chart"
64 local prog_path=$($WHICH_COMMAND $prog_name)
67 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
69 echo "Building bench-graph executables"
71 $BUILD_CHART_EXE || die "build failed"
72 elif test ! -x "$prog_path"
82 build_report_prog || exit 1
84 prog=$(find_report_prog) || \
85 die "Cannot find bench-graph executable"
86 echo "Using bench-graph executable [$prog]"
90# We run the benchmarks in isolation in a separate process so that different
91# benchmarks do not interfere with other. To enable that we need to pass the
92# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
95# The path is dependent on the architecture and cabal version.
96# Use this command to find the exe if this script fails with an error:
97# find .stack-work/ -type f -name "benchmarks"
101 local bench_prog=`stack path --dist-dir`/build/$bench_name/$bench_name
102 if test -x "$bench_prog"
112 local bench_prog=`$WHICH_COMMAND $1`
113 if test -x "$bench_prog"
123 echo "charts/$bench_name/results.csv"
126# --min-duration 0 means exactly one iteration per sample. We use a million
127# iterations in the benchmarking code explicitly and do not use the iterations
128# done by the benchmarking tool.
130# Benchmarking tool by default discards the first iteration to remove
131# aberrations due to initial evaluations etc. We do not discard it because we
132# are anyway doing iterations in the benchmarking code and many of them so that
133# any constant factor gets amortized and anyway it is a cost that we pay in
136# We can pass --min-samples value from the command line as second argument
137# after the benchmark name in case we want to use more than one sample.
141 local output_file=$(bench_output_file $bench_name)
143 bench_prog=$($GET_BENCH_PROG $bench_name) || \
144 die "Cannot find benchmark executable for benchmark $bench_name"
146 mkdir -p `dirname $output_file`
148 echo "Running benchmark $bench_name ..."
151 if test "$LONG" -eq 0
153 if test "$SLOW" -eq 0
155 SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
157 SPEED_OPTIONS="--min-duration 0"
160 SPEED_OPTIONS="--stream-size 10000000 -v2 --quick --include-first-iter --time-limit 1 --min-duration 0"
163 $bench_prog $SPEED_OPTIONS \
164 --csvraw=$output_file \
166 --measure-with $bench_prog $GAUGE_ARGS || die "Benchmarking failed"
176run_benches_comparing() {
179 if test -z "$CANDIDATE"
181 CANDIDATE=$(git rev-parse HEAD)
185 # XXX Should be where the current branch is forked from master
188 echo "Comparing baseline commit [$BASE] with candidate [$CANDIDATE]"
189 echo "Checking out base commit [$BASE] for benchmarking"
190 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
192 $BUILD_BENCH || die "build failed"
193 run_benches "$bench_list"
195 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
196 git checkout "$CANDIDATE" || \
197 die "Checkout of candidate [$CANDIDATE] commit failed"
199 $BUILD_BENCH || die "build failed"
200 run_benches "$bench_list"
201 # XXX reset back to the original commit
204backup_output_file() {
206 local output_file=$(bench_output_file $bench_name)
208 if test -e $output_file -a "$APPEND" != 1
210 mv -f -v $output_file ${output_file}.prev
219 backup_output_file $i
222 if test "$COMPARE" = "0"
224 run_benches "$bench_list"
226 run_benches_comparing "$bench_list"
232 prog=$(find_report_prog) || \
233 die "Cannot find bench-graph executable"
238 echo "Generating reports for ${i}..."
239 $prog $(test "$GRAPH" = 1 && echo "--graphs") \
240 $(test "$GROUP_DIFF" = 1 && echo "--group-diff") \
245#-----------------------------------------------------------------------------
246# Execution starts here
247#-----------------------------------------------------------------------------
249DEFAULT_BENCHMARKS="linear"
267GHC_VERSION=$(ghc --numeric-version)
270 find dist-newstyle -type f -path "*${GHC_VERSION}*/$1"
273#-----------------------------------------------------------------------------
275#-----------------------------------------------------------------------------
280 -h|--help|help) print_help ;;
281 # options with arguments
282 --slow) SLOW=1; shift ;;
283 --benchmarks) shift; BENCHMARKS=$1; shift ;;
284 --base) shift; BASE=$1; shift ;;
285 --candidate) shift; CANDIDATE=$1; shift ;;
287 --compare) COMPARE=1; shift ;;
288 --raw) RAW=1; shift ;;
289 --append) APPEND=1; shift ;;
290 --long) LONG=1; shift ;;
291 --group-diff) GROUP_DIFF=1; shift ;;
292 --graphs) GRAPH=1; shift ;;
293 --no-measure) MEASURE=0; shift ;;
295 -*|--*) print_help ;;
301echo "Using stack command [$STACK]"
304if echo "$BENCHMARKS" | grep -q base
306 STACK_BUILD_FLAGS="--flag streamly:dev"
307 CABAL_BUILD_FLAGS="--flags dev"
312 if test "$i" = concurrent
314 STACK_BUILD_FLAGS="--flag streamly:dev"
315 CABAL_BUILD_FLAGS="--flags dev"
320if test "$USE_STACK" = "1"
322 WHICH_COMMAND="stack exec which"
323 BUILD_CHART_EXE="stack build --flag streamly:dev"
324 GET_BENCH_PROG=stack_bench_prog
325 BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
327 # XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
328 #WHICH_COMMAND="cabal v2-exec which"
329 WHICH_COMMAND=cabal_which
330 BUILD_CHART_EXE="cabal v2-build --flags dev chart"
331 GET_BENCH_PROG=cabal_bench_prog
332 BUILD_BENCH="cabal v2-build $CABAL_BUILD_FLAGS --enable-benchmarks"
335#-----------------------------------------------------------------------------
337#-----------------------------------------------------------------------------
339# We need to build the report progs first at the current (latest) commit before
340# checking out any other commit for benchmarking.
341build_report_progs "$BENCHMARKS"
343#-----------------------------------------------------------------------------
345#-----------------------------------------------------------------------------
347if test "$MEASURE" = "1"
350 $BUILD_BENCH || die "build failed"
351 run_measurements "$BENCHMARKS"
354#-----------------------------------------------------------------------------
356#-----------------------------------------------------------------------------
360 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