@@ -4,6 +4,8 @@
4# BENCH_EXEC_PATH: the benchmark executable
4# BENCH_EXEC_PATH: the benchmark executable
5# RTS_OPTIONS: additional RTS options
5# RTS_OPTIONS: additional RTS options
6# QUICK_MODE: whether we are in quick mode
6# QUICK_MODE: whether we are in quick mode
7+# USE_GAUGE: whether to use gauge or tasty-bench
8+# LONG: whether to use a large stream size
8# $1: message
10# $1: message
@@ -42,6 +44,9 @@ bench_rts_opts_default () {
44# Overrides for specific benchmarks
46# Overrides for specific benchmarks
47+# XXX Note: for tasty-bench we replace the "." separator in the benchmark names
48+# with "/" for matching with this. It may not work reliably if the benchmark
49+# name already contains ".".
45bench_rts_opts_specific () {
50bench_rts_opts_specific () {
46 case "$1" in
51 case "$1" in
47 Data.Stream.StreamD/o-n-space/elimination/toList) echo -n "-K2M" ;;
52 Data.Stream.StreamD/o-n-space/elimination/toList) echo -n "-K2M" ;;
@@ -103,43 +108,46 @@ bench_rts_opts_specific () {
103if test "$USE_GAUGE" -eq 0
108if test "$USE_GAUGE" -eq 0
105 SUPER_QUICK_OPTIONS="--stdev 1000000"
110 SUPER_QUICK_OPTIONS="--stdev 1000000"
106− QUICKER_OPTIONS="--stdev 1000"
111+ QUICKER_OPTIONS="--stdev 100"
108 # Do not keep time limit as 0 otherwise GC stats may remain 0 in some cases.
113 # Do not keep time limit as 0 otherwise GC stats may remain 0 in some cases.
109 SUPER_QUICK_OPTIONS="--quick --min-duration 0 --time-limit 0.01 --include-first-iter"
114 SUPER_QUICK_OPTIONS="--quick --min-duration 0 --time-limit 0.01 --include-first-iter"
110 QUICKER_OPTIONS="--min-samples 3 --time-limit 1"
115 QUICKER_OPTIONS="--min-samples 3 --time-limit 1"
118+# tasty-bench does not like an option set twice
119+set_super_quick_mode () {
113# For certain long benchmarks if the user has not requested super quick
123# For certain long benchmarks if the user has not requested super quick
114# mode we anyway use a slightly quicker mode.
124# mode we anyway use a slightly quicker mode.
115use_quicker_mode () {
125use_quicker_mode () {
116− if test -n "$QUICK_MODE"
126+ if test "$QUICK_MODE" -eq 0
118− if test "$QUICK_MODE" -eq 0
128+ echo quicker
120− echo $QUICKER_OPTIONS
125bench_exe_quick_opts () {
132bench_exe_quick_opts () {
126 case "$1" in
133 case "$1" in
127− Prelude.Concurrent) echo -n "$SUPER_QUICK_OPTIONS" ;;
134+ Prelude.Concurrent) set_super_quick_mode ;;
128− Prelude.Rate) echo -n "$SUPER_QUICK_OPTIONS" ;;
135+ Prelude.Rate) set_super_quick_mode ;;
129− Prelude.Adaptive) echo -n "$SUPER_QUICK_OPTIONS" ;;
136+ Prelude.Adaptive) set_super_quick_mode;;
130 *) echo -n "" ;;
137 *) echo -n "" ;;
141+# XXX Note: for tasty-bench we replace the "." separator in the benchmark names
142+# with "/" for matching with this. It may not work reliably if the benchmark
143+# name already contains ".".
134# Use quick options for benchmarks that take too long
145# Use quick options for benchmarks that take too long
135bench_quick_opts () {
146bench_quick_opts () {
136 case "$1" in
147 case "$1" in
137− Prelude.Parallel/o-n-heap/mapping/mapM)
148+ Prelude.Parallel/o-n-heap/mapping/mapM) set_super_quick_mode ;;
138− echo -n "$SUPER_QUICK_OPTIONS" ;;
139− Prelude.Parallel/o-n-heap/monad-outer-product/*)
149+ Prelude.Parallel/o-n-heap/monad-outer-product/*) set_super_quick_mode ;;
140− echo -n "$SUPER_QUICK_OPTIONS" ;;
141− Prelude.Parallel/o-n-space/monad-outer-product/*)
150+ Prelude.Parallel/o-n-space/monad-outer-product/*) set_super_quick_mode ;;
142− echo -n "$SUPER_QUICK_OPTIONS" ;;
143 Prelude.Parallel/o-n-heap/generation/*) use_quicker_mode ;;
151 Prelude.Parallel/o-n-heap/generation/*) use_quicker_mode ;;
144 Prelude.Parallel/o-n-heap/mapping/*) use_quicker_mode ;;
152 Prelude.Parallel/o-n-heap/mapping/*) use_quicker_mode ;;
145 Prelude.Parallel/o-n-heap/concat-foldable/*) use_quicker_mode ;;
153 Prelude.Parallel/o-n-heap/concat-foldable/*) use_quicker_mode ;;
@@ -163,11 +171,12 @@ bench_output_file() {
163 echo "charts/$bench_name/results.csv"
171 echo "charts/$bench_name/results.csv"
166−BENCH_NAME_ORIG=""
174+#------------------------------------------------------------------------------
167−for i in "$@"
175+# Determine options from benchmark name
168−do
176+#------------------------------------------------------------------------------
169− BENCH_NAME_ORIG="$i"
178+BENCH_NAME_ORIG="$1"
172if test "$USE_GAUGE" -eq 0
181if test "$USE_GAUGE" -eq 0
@@ -178,16 +187,8 @@ then
178 BENCH_NAME1=$(echo $BENCH_NAME | cut -f1 -d '/')
187 BENCH_NAME1=$(echo $BENCH_NAME | cut -f1 -d '/')
179 BENCH_NAME2=$(echo $BENCH_NAME | cut -f2- -d '/' | sed -e 's/\./\//g')
188 BENCH_NAME2=$(echo $BENCH_NAME | cut -f2- -d '/' | sed -e 's/\./\//g')
180 BENCH_NAME="$BENCH_NAME1/$BENCH_NAME2"
189 BENCH_NAME="$BENCH_NAME1/$BENCH_NAME2"
183 BENCH_NAME=$BENCH_NAME_ORIG
191 BENCH_NAME=$BENCH_NAME_ORIG
186−if test "$LONG" -eq 0
190− SIZE_OPT="--stream-size 1000000"
193RTS_OPTIONS=\
194RTS_OPTIONS=\
@@ -198,28 +199,65 @@ $(bench_rts_opts_specific $BENCH_NAME) \
198$RTS_OPTIONS \
199$RTS_OPTIONS \
201−QUICK_BENCH_OPTIONS="\
202+QUICK_MODE_TYPE="\
202−$(if test "$QUICK_MODE" -ne 0; then echo $SUPER_QUICK_OPTIONS; else :; fi)
203+$(if test "$QUICK_MODE" -ne 0; then set_super_quick_mode; fi) \
203$(bench_exe_quick_opts $(basename $BENCH_EXEC_PATH)) \
204$(bench_exe_quick_opts $(basename $BENCH_EXEC_PATH)) \
204$(bench_quick_opts $BENCH_NAME)"
205$(bench_quick_opts $BENCH_NAME)"
206−output_file=$(bench_output_file $(basename $BENCH_EXEC_PATH))
207+for i in $QUICK_MODE_TYPE
207−mkdir -p `dirname $output_file`
208+do
210+ super_quick) QUICK_BENCH_OPTIONS="$SUPER_QUICK_OPTIONS"; break ;;
211+ quicker) QUICK_BENCH_OPTIONS="$QUICKER_OPTIONS"; break ;;
215+if test "$LONG" -ne 0
217+ STREAM_SIZE=10000000
218+ STREAM_LEN=$(env LC_ALL=en_US.UTF-8 printf "--stream-size %'.f\n" $STREAM_SIZE)
219+ STREAM_SIZE_OPT="--stream-size $STREAM_SIZE"
209echo "$BENCH_NAME: \
222echo "$BENCH_NAME: \
210−$QUICK_BENCH_OPTIONS \
225+$QUICK_BENCH_OPTIONS" \
211−$RTS_OPTIONS"
226+"$@"
228+#------------------------------------------------------------------------------
229+# Run benchmark with options and collect results
230+#------------------------------------------------------------------------------
232+output_file=$(bench_output_file $(basename $BENCH_EXEC_PATH))
233+mkdir -p `dirname $output_file`
213rm -f ${output_file}.tmp
234rm -f ${output_file}.tmp
214if test $USE_GAUGE -eq 0
236if test $USE_GAUGE -eq 0
238+ # Escape "\" and double quotes in benchmark names
216 BENCH_NAME_ESC=$(echo "$BENCH_NAME_ORIG" | sed -e 's/\\/\\\\/g' | sed -e 's/"/\\"/g')
239 BENCH_NAME_ESC=$(echo "$BENCH_NAME_ORIG" | sed -e 's/\\/\\\\/g' | sed -e 's/"/\\"/g')
217− $BENCH_EXEC_PATH $SIZE_OPT $JOB_OPT $RTS_OPTIONS $QUICK_BENCH_OPTIONS --csv=${output_file}.tmp \
240+ $BENCH_EXEC_PATH \
244+ $QUICK_BENCH_OPTIONS \
246+ --csv=${output_file}.tmp \
218 -p '$0 == "'"$BENCH_NAME_ESC"'"'
247 -p '$0 == "'"$BENCH_NAME_ESC"'"'
249+ # Convert cpuTime field from picoseconds to seconds
219 tail -n +2 ${output_file}.tmp | \
250 tail -n +2 ${output_file}.tmp | \
220− awk 'BEGIN {FPAT = "([^,]+)|(\"[^\"]+\")";OFS=","} {$2=$2/1000000000000;print}' >> $output_file
251+ awk 'BEGIN {FPAT = "([^,]+)|(\"[^\"]+\")";OFS=","} {$2=$2/1000000000000;print}' \
257+ $QUICK_BENCH_OPTIONS \
222− $BENCH_EXEC_PATH $SIZE_OPT $RTS_OPTIONS $QUICK_BENCH_OPTIONS --csvraw=${output_file}.tmp \
259+ --csvraw=${output_file}.tmp \
223 -m exact "$BENCH_NAME"
260 -m exact "$BENCH_NAME"
224− tail -n +2 ${output_file}.tmp >> $output_file
261+ tail -n +2 ${output_file}.tmp \