5 echo " [--benchmarks <all|linear|linear-async|linear-rate|nested|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 guage"
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=$($STACK exec which $prog_name)
50 if test -x "$prog_path"
58# $1: benchmark name (linear, nested, base)
60 local prog_name="chart"
61 local prog_path=$($STACK exec which $prog_name)
64 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
66 echo "Building bench-graph executables"
68 $STACK build --flag "streamly:dev" || 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 guage 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 echo "charts/$bench_name/results.csv"
112# --min-duration 0 means exactly one iteration per sample. We use a million
113# iterations in the benchmarking code explicitly and do not use the iterations
114# done by the benchmarking tool.
116# Benchmarking tool by default discards the first iteration to remove
117# aberrations due to initial evaluations etc. We do not discard it because we
118# are anyway doing iterations in the benchmarking code and many of them so that
119# any constant factor gets amortized and anyway it is a cost that we pay in
122# We can pass --min-samples value from the command line as second argument
123# after the benchmark name in case we want to use more than one sample.
127 local output_file=$(bench_output_file $bench_name)
129 bench_prog=$(find_bench_prog $bench_name) || \
130 die "Cannot find benchmark executable for benchmark $bench_name"
132 mkdir -p `dirname $output_file`
134 echo "Running benchmark $bench_name ..."
136 $bench_prog $SPEED_OPTIONS \
137 --csvraw=$output_file \
139 --measure-with $bench_prog $GAUGE_ARGS || die "Benchmarking failed"
149run_benches_comparing() {
152 if test -z "$CANDIDATE"
154 CANDIDATE=$(git rev-parse HEAD)
158 # XXX Should be where the current branch is forked from master
161 echo "Comparing baseline commit [$BASE] with candidate [$CANDIDATE]"
162 echo "Checking out base commit [$BASE] for benchmarking"
163 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
165 $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
166 run_benches "$bench_list"
168 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
169 git checkout "$CANDIDATE" || \
170 die "Checkout of candidate [$CANDIDATE] commit failed"
172 $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
173 run_benches "$bench_list"
174 # XXX reset back to the original commit
177backup_output_file() {
179 local output_file=$(bench_output_file $bench_name)
181 if test -e $output_file -a "$APPEND" != 1
183 mv -f -v $output_file ${output_file}.prev
192 backup_output_file $i
195 if test "$COMPARE" = "0"
197 run_benches "$bench_list"
199 run_benches_comparing "$bench_list"
205 prog=$(find_report_prog) || \
206 die "Cannot find bench-graph executable"
211 echo "Generating reports for ${i}..."
212 $prog $(test "$GRAPH" = 1 && echo "--graphs") \
213 $(test "$GROUP_DIFF" = 1 && echo "--group-diff") \
218#-----------------------------------------------------------------------------
219# Execution starts here
220#-----------------------------------------------------------------------------
222DEFAULT_BENCHMARKS="linear"
223ALL_BENCHMARKS="linear linear-async linear-rate nested base"
234SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
241#-----------------------------------------------------------------------------
243#-----------------------------------------------------------------------------
248 -h|--help|help) print_help ;;
249 # options with arguments
250 --slow) SPEED_OPTIONS="--min-duration 0"; shift ;;
251 --benchmarks) shift; BENCHMARKS=$1; shift ;;
252 --base) shift; BASE=$1; shift ;;
253 --candidate) shift; CANDIDATE=$1; shift ;;
255 --compare) COMPARE=1; shift ;;
256 --raw) RAW=1; shift ;;
257 --append) APPEND=1; shift ;;
258 --group-diff) GROUP_DIFF=1; shift ;;
259 --graphs) GRAPH=1; shift ;;
260 --no-measure) MEASURE=0; shift ;;
262 -*|--*) print_help ;;
268echo "Using stack command [$STACK]"
271if echo "$BENCHMARKS" | grep -q base
273 STACK_BUILD_FLAGS="--flag streamly:dev"
276#-----------------------------------------------------------------------------
278#-----------------------------------------------------------------------------
280# We need to build the report progs first at the current (latest) commit before
281# checking out any other commit for benchmarking.
282build_report_progs "$BENCHMARKS"
284#-----------------------------------------------------------------------------
286#-----------------------------------------------------------------------------
288if test "$MEASURE" = "1"
290 $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
291 run_measurements "$BENCHMARKS"
294#-----------------------------------------------------------------------------
296#-----------------------------------------------------------------------------
300 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