on master help sign in
use cabal for building benchmarks
24b044aHarendra Kumar
bench.sh+35−11
@@ -46,7 +46,7 @@ set_benchmarks() {
46find_report_prog() {
46find_report_prog() {
47 local prog_name="chart"
47 local prog_name="chart"
48 hash -r
48 hash -r
49− local prog_path=$($STACK exec which $prog_name)
49+ local prog_path=$($WHICH_COMMAND $prog_name)
50 if test -x "$prog_path"
50 if test -x "$prog_path"
51 then
51 then
52 echo $prog_path
52 echo $prog_path
@@ -58,14 +58,14 @@ find_report_prog() {
58# $1: benchmark name (linear, nested, base)
58# $1: benchmark name (linear, nested, base)
59build_report_prog() {
59build_report_prog() {
60 local prog_name="chart"
60 local prog_name="chart"
61− local prog_path=$($STACK exec which $prog_name)
61+ local prog_path=$($WHICH_COMMAND $prog_name)
62
62
63 hash -r
63 hash -r
64 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
64 if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0"
65 then
65 then
66 echo "Building bench-graph executables"
66 echo "Building bench-graph executables"
67 BUILD_ONCE=1
67 BUILD_ONCE=1
68− $STACK build --flag "streamly:dev" || die "build failed"
68+ $BUILD_CHART_EXE || die "build failed"
69 elif test ! -x "$prog_path"
69 elif test ! -x "$prog_path"
70 then
70 then
71 return 1
71 return 1
@@ -93,9 +93,20 @@ build_report_progs() {
93# Use this command to find the exe if this script fails with an error:
93# Use this command to find the exe if this script fails with an error:
94# find .stack-work/ -type f -name "benchmarks"
94# find .stack-work/ -type f -name "benchmarks"
95
95
96−find_bench_prog () {
96+stack_bench_prog () {
97 local bench_name=$1
97 local bench_name=$1
98− local bench_prog=`$STACK path --dist-dir`/build/$bench_name/$bench_name
98+ local bench_prog=`stack path --dist-dir`/build/$bench_name/$bench_name
99+ if test -x "$bench_prog"
100+ then
101+ echo $bench_prog
102+ else
103+ return 1
104+ fi
105+}
106+
107+cabal_bench_prog () {
108+ local bench_name=$1
109+ local bench_prog=`$WHICH_COMMAND $1`
99 if test -x "$bench_prog"
110 if test -x "$bench_prog"
100 then
111 then
101 echo $bench_prog
112 echo $bench_prog
@@ -126,7 +137,7 @@ run_bench () {
126 local bench_name=$1
137 local bench_name=$1
127 local output_file=$(bench_output_file $bench_name)
138 local output_file=$(bench_output_file $bench_name)
128 local bench_prog
139 local bench_prog
129− bench_prog=$(find_bench_prog $bench_name) || \
140+ bench_prog=$($GET_BENCH_PROG $bench_name) || \
130 die "Cannot find benchmark executable for benchmark $bench_name"
141 die "Cannot find benchmark executable for benchmark $bench_name"
131
142
132 mkdir -p `dirname $output_file`
143 mkdir -p `dirname $output_file`
@@ -162,14 +173,14 @@ run_benches_comparing() {
162 echo "Checking out base commit [$BASE] for benchmarking"
173 echo "Checking out base commit [$BASE] for benchmarking"
163 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
174 git checkout "$BASE" || die "Checkout of base commit [$BASE] failed"
164
175
165− $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
176+ $BUILD_BENCH || die "build failed"
166 run_benches "$bench_list"
177 run_benches "$bench_list"
167
178
168 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
179 echo "Checking out candidate commit [$CANDIDATE] for benchmarking"
169 git checkout "$CANDIDATE" || \
180 git checkout "$CANDIDATE" || \
170 die "Checkout of candidate [$CANDIDATE] commit failed"
181 die "Checkout of candidate [$CANDIDATE] commit failed"
171
182
172− $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
183+ $BUILD_BENCH || die "build failed"
173 run_benches "$bench_list"
184 run_benches "$bench_list"
174 # XXX reset back to the original commit
185 # XXX reset back to the original commit
175}
186}
@@ -233,10 +244,22 @@ GRAPH=0
233MEASURE=1
244MEASURE=1
234SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
245SPEED_OPTIONS="--quick --min-samples 10 --time-limit 1 --min-duration 0"
235
246
236−STACK=stack
237GAUGE_ARGS=
247GAUGE_ARGS=
238−
239BUILD_ONCE=0
248BUILD_ONCE=0
249+USE_STACK=0
250+
251+if test "$USE_STACK" = "1"
252+then
253+ WHICH_COMMAND="stack exec which"
254+ BUILD_CHART_EXE="stack build --flag streamly:dev"
255+ GET_BENCH_PROG=stack_bench_prog
256+ BUILD_BENCH="stack build $STACK_BUILD_FLAGS --bench --no-run-benchmarks"
257+else
258+ WHICH_COMMAND="cabal v2-exec which"
259+ BUILD_CHART_EXE="cabal v2-build --flags dev chart"
260+ GET_BENCH_PROG=cabal_bench_prog
261+ BUILD_BENCH="cabal v2-build $CABAL_BUILD_FLAGS --enable-benchmarks"
262+fi
240
263
241#-----------------------------------------------------------------------------
264#-----------------------------------------------------------------------------
242# Read command line
265# Read command line
@@ -271,6 +294,7 @@ set_benchmarks
271if echo "$BENCHMARKS" | grep -q base
294if echo "$BENCHMARKS" | grep -q base
272then
295then
273 STACK_BUILD_FLAGS="--flag streamly:dev"
296 STACK_BUILD_FLAGS="--flag streamly:dev"
297+ CABAL_BUILD_FLAGS="--flags dev"
274fi
298fi
275
299
276#-----------------------------------------------------------------------------
300#-----------------------------------------------------------------------------
@@ -287,7 +311,7 @@ build_report_progs "$BENCHMARKS"
287
311
288if test "$MEASURE" = "1"
312if test "$MEASURE" = "1"
289then
313then
290− $STACK build $STACK_BUILD_FLAGS --bench --no-run-benchmarks || die "build failed"
314+ $BUILD_BENCH || die "build failed"
291 run_measurements "$BENCHMARKS"
315 run_measurements "$BENCHMARKS"
292fi
316fi
293
317