5 echo " [--benchmarks <all|linear|linear-async|linear-rate|nested|concurrent|fileio|array|base>]"
10 echo " [--compare] [--base commit] [--candidate commit]"
12 echo " -- <gauge options>"
14 echo "Multiple benchmarks can be specified as a space separate list"
15 echo " e.g. --benchmarks \"linear nested\""
17 echo "--group-diff is used to compare groups within a single benchmark"
18 echo " e.g. StreamD vs StreamK in base benchmark."
20 echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
21 echo "commit is generated, in the 'charts' directory."
22 echo "Use --base and --candidate to select the commits to compare."
24 echo "Any arguments after a '--' are passed directly to gauge"
30 >&2 echo -e "Error: $1"
35 if test -z "$BENCHMARKS"
37 BENCHMARKS=$DEFAULT_BENCHMARKS
38 elif test "$BENCHMARKS" = "all"
40 BENCHMARKS=$ALL_BENCHMARKS
42 echo "Using benchmark suites [$BENCHMARKS]"
45# $1: benchmark name (linear, nested, base)
47 local prog_name="chart"
49 local prog_path=$($WHICH_COMMAND $prog_name)
50 if test -x "$prog_path"
58# $1: benchmark name (linear, nested, base)
60 local prog_name="chart"
61 local prog_path=$($WHICH_COMMAND $prog_name)
64 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
66 echo "Building bench-graph executables"
68 $BUILD_CHART_EXE || die "build failed"
69 elif test ! -x "$prog_path"
79 build_report_prog || exit 1
81 prog=$(find_report_prog) || \
82 die "Cannot find bench-graph executable"
83 echo "Using bench-graph executable [$prog]"
87# We run the benchmarks in isolation in a separate process so that different
88# benchmarks do not interfere with other. To enable that we need to pass the
89# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
92# The path is dependent on the architecture and cabal version.
93# Use this command to find the exe if this script fails with an error:
94# find .stack-work/ -type f -name "benchmarks"
98 local bench_prog=`stack path --dist-dir`/build/$bench_name/$bench_name
99 if test -x "$bench_prog"
109 local bench_prog=`$WHICH_COMMAND $1`
110 if test -x "$bench_prog"
120 echo "charts/$bench_name/results.csv"
123# --min-duration 0 means exactly one iteration per sample. We use a million
124# iterations in the benchmarking code explicitly and do not use the iterations
125# done by the benchmarking tool.
127# Benchmarking tool by default discards the first iteration to remove
128# aberrations due to initial evaluations etc. We do not discard it because we
129# are anyway doing iterations in the benchmarking code and many of them so that
130# any constant factor gets amortized and anyway it is a cost that we pay in
133# We can pass --min-samples value from the command line as second argument
134# after the benchmark name in case we want to use more than one sample.
138 local output_file=$(bench_output_file $bench_name)
140 bench_prog=$($GET_BENCH_PROG $bench_name) || \
141 die "Cannot find benchmark executable for benchmark $bench_name"
143 mkdir -p `dirname $output_file`
145 echo "Running benchmark $bench_name ..."
147 $bench_prog $SPEED_OPTIONS \
148 --csvraw=$output_file \
150 --measure-with $bench_prog $GAUGE_ARGS || die "Benchmarking failed"
160run_benches_comparing() {
163 if test -z "$CANDIDATE"
165 CANDIDATE=$(git rev-parse HEAD)
169 # XXX Should be where the current branch is forked from master
172 echo "Comparing baseline commit [$BASE] with candidate [$CANDIDATE]"
173 echo "Checking out base commit [$BASE] for benchmarking"
174 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
176 $BUILD_BENCH || die "build failed"
177 run_benches "$bench_list"
179 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
180 git checkout "$CANDIDATE" || \
181 die "Checkout of candidate [$CANDIDATE] commit failed"
183 $BUILD_BENCH || die "build failed"
184 run_benches "$bench_list"
185 # XXX reset back to the original commit
188backup_output_file() {
190 local output_file=$(bench_output_file $bench_name)
192 if test -e $output_file -a "$APPEND" != 1
194 mv -f -v $output_file ${output_file}.prev
203 backup_output_file $i
206 if test "$COMPARE" = "0"
208 run_benches "$bench_list"
210 run_benches_comparing "$bench_list"
216 prog=$(find_report_prog) || \
217 die "Cannot find bench-graph executable"
222 echo "Generating reports for ${i}..."
223 $prog $(test "$GRAPH" = 1 && echo "--graphs") \
224 $(test "$GROUP_DIFF" = 1 && echo "--group-diff") \
229#-----------------------------------------------------------------------------
230# Execution starts here
231#-----------------------------------------------------------------------------
233DEFAULT_BENCHMARKS="linear"
234ALL_BENCHMARKS="linear linear-async linear-rate nested concurrrent fileio array base"
245SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
251GHC_VERSION=$(ghc --numeric-version)
254 find dist-newstyle -type f -path "*${GHC_VERSION}*/$1"
257#-----------------------------------------------------------------------------
259#-----------------------------------------------------------------------------
264 -h|--help|help) print_help ;;
265 # options with arguments
266 --slow) SPEED_OPTIONS="--min-duration 0"; shift ;;
267 --benchmarks) shift; BENCHMARKS=$1; shift ;;
268 --base) shift; BASE=$1; shift ;;
269 --candidate) shift; CANDIDATE=$1; shift ;;
271 --compare) COMPARE=1; shift ;;
272 --raw) RAW=1; shift ;;
273 --append) APPEND=1; shift ;;
274 --group-diff) GROUP_DIFF=1; shift ;;
275 --graphs) GRAPH=1; shift ;;
276 --no-measure) MEASURE=0; shift ;;
278 -*|--*) print_help ;;
284echo "Using stack command [$STACK]"
287if echo "$BENCHMARKS" | grep -q base
289 STACK_BUILD_FLAGS="--flag streamly:dev"
290 CABAL_BUILD_FLAGS="--flags dev"
293if echo "$BENCHMARKS" | grep -q concurrent
295 STACK_BUILD_FLAGS="--flag streamly:dev"
296 CABAL_BUILD_FLAGS="--flags dev"
299if test "$USE_STACK" = "1"
301 WHICH_COMMAND="stack exec which"
302 BUILD_CHART_EXE="stack build --flag streamly:dev"
303 GET_BENCH_PROG=stack_bench_prog
304 BUILD_BENCH="stack build $STACK_BUILD_FLAGS --flags "streamly:benchmark" --bench --no-run-benchmarks"
306 # XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
307 #WHICH_COMMAND="cabal v2-exec which"
308 WHICH_COMMAND=cabal_which
309 BUILD_CHART_EXE="cabal v2-build --flags dev chart"
310 GET_BENCH_PROG=cabal_bench_prog
311 BUILD_BENCH="cabal v2-build $CABAL_BUILD_FLAGS --flag benchmark --enable-benchmarks"
314#-----------------------------------------------------------------------------
316#-----------------------------------------------------------------------------
318# We need to build the report progs first at the current (latest) commit before
319# checking out any other commit for benchmarking.
320build_report_progs "$BENCHMARKS"
322#-----------------------------------------------------------------------------
324#-----------------------------------------------------------------------------
326if test "$MEASURE" = "1"
329 $BUILD_BENCH || die "build failed"
330 run_measurements "$BENCHMARKS"
333#-----------------------------------------------------------------------------
335#-----------------------------------------------------------------------------
339 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