on master help sign in
Refactor and improve error reporting
2b8c70bHarendra Kumar
benchmark/bench-report/bin/bench-runner.sh+8−3
@@ -247,7 +247,7 @@ $RTS_OPTIONS \
247 $QUICK_BENCH_OPTIONS \
247 $QUICK_BENCH_OPTIONS \
248 "$@" \
248 "$@" \
249 --csv=${output_file}.tmp \
249 --csv=${output_file}.tmp \
250− -p '$0 == "'"$BENCH_NAME_ESC"'"'
250+ -p '$0 == "'"$BENCH_NAME_ESC"'"' || die "Benchmark execution failed."
251
251
252 # Convert cpuTime field from picoseconds to seconds
252 # Convert cpuTime field from picoseconds to seconds
253 awk --version 2>&1 | grep -q "GNU Awk" \
253 awk --version 2>&1 | grep -q "GNU Awk" \
@@ -262,7 +262,7 @@ $RTS_OPTIONS \
262 $QUICK_BENCH_OPTIONS \
262 $QUICK_BENCH_OPTIONS \
263 "$@" \
263 "$@" \
264 --csvraw=${output_file}.tmp \
264 --csvraw=${output_file}.tmp \
265− -m exact "$BENCH_NAME"
265+ -m exact "$BENCH_NAME" || die "Benchmark execution failed."
266 tail -n +2 ${output_file}.tmp \
266 tail -n +2 ${output_file}.tmp \
267 >> $output_file
267 >> $output_file
268 fi
268 fi
@@ -321,7 +321,12 @@ run_bench_target () {
321 local target_name=$3
321 local target_name=$3
322
322
323 local target_prog
323 local target_prog
324+ if test -z "$BENCHMARK_PACKAGE_VERSION"
325+ then
326+ echo "Please set BENCHMARK_PACKAGE_VERSION in bench_config"
327+ exit 1
328+ fi
324− target_prog=$(cabal_target_prog $package_name $component $target_name) || \
329+ target_prog=$(cabal_target_prog $package_name-$BENCHMARK_PACKAGE_VERSION $component $target_name) || \
325 die "Cannot find executable for target $target_name"
330 die "Cannot find executable for target $target_name"
326
331
327 echo "Running executable $target_name ..."
332 echo "Running executable $target_name ..."
benchmark/bench-report/bin/build-lib.sh+19−63
@@ -112,6 +112,24 @@ set_targets() {
112 fi
112 fi
113}
113}
114
114
115+# XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
116+
117+# $1: builddir
118+# $2: package name with version
119+# $3: component ("" (lib), t (test), b (benchmark), x (executable))
120+# $4: command to find
121+cabal_which_builddir() {
122+ local path=$(echo $1/build/*/ghc-${GHC_VERSION}/${2}/$3/$4/build/$4/$4)
123+ test -f "$path" && echo $path
124+}
125+
126+# $1: package name with version
127+# $2: component
128+# $3: command to find
129+cabal_which() {
130+ cabal_which_builddir $BUILD_DIR $1 $2 $3
131+}
132+
115# We run the benchmarks in isolation in a separate process so that different
133# We run the benchmarks in isolation in a separate process so that different
116# benchmarks do not interfere with other. To enable that we need to pass the
134# benchmarks do not interfere with other. To enable that we need to pass the
117# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
135# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
@@ -119,7 +137,7 @@ set_targets() {
119
137
120# The path is dependent on the architecture and cabal version.
138# The path is dependent on the architecture and cabal version.
121
139
122−# $1: package name
140+# $1: package name with version
123# $2: component
141# $2: component
124# $3: target
142# $3: target
125cabal_target_prog () {
143cabal_target_prog () {
@@ -169,24 +187,6 @@ set_derived_vars () {
169 GHC_VERSION=$($CABAL_WITH_COMPILER --numeric-version)
187 GHC_VERSION=$($CABAL_WITH_COMPILER --numeric-version)
170}
188}
171
189
172−# XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
173−
174−# $1: builddir
175−# $2: package name
176−# $3: component ("" (lib), t (test), b (benchmark), x (executable))
177−# $4: command to find
178−cabal_which_builddir() {
179− local path=$(echo $1/build/*/ghc-${GHC_VERSION}/${2}-0.0.0/$3/$4/build/$4/$4)
180− test -f "$path" && echo $path
181−}
182−
183−# $1: package name
184−# $2: component
185−# $3: command to find
186−cabal_which() {
187− cabal_which_builddir $BUILD_DIR $1 $2 $3
188−}
189−
190# $1: build program
190# $1: build program
191# $2: package name
191# $2: package name
192# $3: component prefix
192# $3: component prefix
@@ -204,47 +204,3 @@ run_build () {
204 done
204 done
205 run_verbose $build_prog $COMPONENTS || die "build failed"
205 run_verbose $build_prog $COMPONENTS || die "build failed"
206}
206}
207−
208−# $1: target name
209−get_tix_file () {
210− echo $BUILD_DIR/build/$SYSTEM/ghc-${GHC_VERSION}/$PACKAGE_FULL_NAME/hpc/vanilla/tix/$1/$1.tix
211−}
212−
213−# $1: package name
214−# $2: component
215−# $3: target
216−# $4: args generator func
217−run_target () {
218− local package_name=$1
219− local component=$2
220− local target_name=$3
221− local extra_args=$4
222−
223− local target_prog
224− target_prog=$(cabal_target_prog $package_name $component $target_name) || \
225− die "Cannot find executable for target $target_name"
226−
227− echo "Running executable $target_name ..."
228−
229− # Needed by bench-exec-one.sh
230− export BENCH_EXEC_PATH=$target_prog
231− mkdir -p $(dirname $(get_tix_file $target_name))
232− export HPCTIXFILE=$(get_tix_file $target_name)
233−
234− run_verbose $target_prog $($extra_args $target_name $target_prog) \
235− || die "Target exe failed"
236−
237− # hpc-coveralls fails if there is an empty dir and no .tix file generated
238− rmdir $(dirname $(get_tix_file $target_name)) 2>/dev/null || true
239−}
240−
241−# $1: package name
242−# $2: component
243−# $3: targets
244−# $4: args generator func
245−run_targets() {
246− for i in $3
247− do
248− run_target $1 $2 $i $4
249− done
250−}
benchmark/bench-report/default.nix+1−1
@@ -47,4 +47,4 @@ let haskellPackages =
47 };
47 };
48in if nixpkgs.lib.inNixShell
48in if nixpkgs.lib.inNixShell
49 then shell
49 then shell
50− else (mkHaskellPackages false).streamly
50+ else (mkHaskellPackages false).bench-report
bin/bench-config.sh+6−6
@@ -42,8 +42,13 @@ bench_rts_options () {
42 *) echo -n "" ;;
42 *) echo -n "" ;;
43 esac
43 esac
44
44
45− echo " "
45+ echo -n " "
46+ case "$exe_name" in
47+ Prelude.Concurrent*) echo -n "-K256K -M384M" ;;
48+ *) echo -n "" ;;
49+ esac
46
50
51+ echo -n " "
47 # Based on specific benchmark
52 # Based on specific benchmark
48 # XXX Note: for tasty-bench we replace the "." separator in the benchmark names
53 # XXX Note: for tasty-bench we replace the "." separator in the benchmark names
49 # with "/" for matching with this. It may not work reliably if the benchmark
54 # with "/" for matching with this. It may not work reliably if the benchmark
@@ -106,11 +111,6 @@ bench_rts_options () {
106 Data.Array.Foreign/o-1-space/elimination/foldable/sum) echo -n "-K8M" ;;
111 Data.Array.Foreign/o-1-space/elimination/foldable/sum) echo -n "-K8M" ;;
107 *) echo -n "" ;;
112 *) echo -n "" ;;
108 esac
113 esac
109−
110− case "$exe_name" in
111− Prelude.Concurrent*) echo -n " -K256K -M384M" ;;
112− *) echo -n "" ;;
113− esac
114}
114}
115
115
116#------------------------------------------------------------------------------
116#------------------------------------------------------------------------------
bin/test.sh+45−1
@@ -156,9 +156,53 @@ fi
156# Run targets
156# Run targets
157#-----------------------------------------------------------------------------
157#-----------------------------------------------------------------------------
158
158
159+# $1: target name
160+get_tix_file () {
161+ echo $BUILD_DIR/build/$SYSTEM/ghc-${GHC_VERSION}/$PACKAGE_FULL_NAME/hpc/vanilla/tix/$1/$1.tix
162+}
163+
164+# $1: package name
165+# $2: component
166+# $3: target
167+# $4: args generator func
168+run_target () {
169+ local package_name=$1
170+ local component=$2
171+ local target_name=$3
172+ local extra_args=$4
173+
174+ local target_prog
175+ target_prog=$(cabal_target_prog $package_name $component $target_name) || \
176+ die "Cannot find executable for target $target_name"
177+
178+ echo "Running executable $target_name ..."
179+
180+ # Needed by bench-exec-one.sh
181+ export BENCH_EXEC_PATH=$target_prog
182+ mkdir -p $(dirname $(get_tix_file $target_name))
183+ export HPCTIXFILE=$(get_tix_file $target_name)
184+
185+ run_verbose $target_prog $($extra_args $target_name $target_prog) \
186+ || die "Target exe failed"
187+
188+ # hpc-coveralls fails if there is an empty dir and no .tix file generated
189+ rmdir $(dirname $(get_tix_file $target_name)) 2>/dev/null || true
190+}
191+
192+# $1: package name with version
193+# $2: component
194+# $3: targets
195+# $4: args generator func
196+run_targets() {
197+ for i in $3
198+ do
199+ run_target $1 $2 $i $4
200+ done
201+}
202+
159if test "$MEASURE" -eq "1"
203if test "$MEASURE" -eq "1"
160then
204then
161−run_targets streamly-tests t "$TARGETS" target_exe_extra_args
205+run_targets "streamly-tests-0.0.0" t "$TARGETS" target_exe_extra_args
162fi
206fi
163
207
164#-----------------------------------------------------------------------------
208#-----------------------------------------------------------------------------