From cffe01216b525cb97bd9783577dc912b284b749e Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Sun, 4 Jul 2021 03:16:56 +0530 Subject: [PATCH] Move the bench-runner script to bench-report pkg --- benchmark/bench-report/bin/bench-runner.sh | 39 ++++------------------ bin/bench-config.sh | 2 +- bin/bench.sh | 14 +++++++- streamly.cabal | 4 +-- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/benchmark/bench-report/bin/bench-runner.sh b/benchmark/bench-report/bin/bench-runner.sh index af92cf982..e0d3a474a 100755 --- a/benchmark/bench-report/bin/bench-runner.sh +++ b/benchmark/bench-report/bin/bench-runner.sh @@ -77,39 +77,17 @@ list_comparisons () { echo } -# chart is expensive to build and usually not required to be rebuilt -cabal_which_report() { - local path="./bin/$1" - if test -e "$path" - then - echo $path - fi -} - -find_report_prog() { - local prog_name="bench-report" - hash -r - local prog_path=$(cabal_which_report $prog_name) - if test -x "$prog_path" - then - echo $prog_path - else - return 1 - fi -} - build_report_prog() { - local prog_name="bench-report" - local prog_path=$(cabal_which_report $prog_name) + local prog_path=$BENCH_REPORT_DIR/bin/bench-report hash -r if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0" then echo "Building bench-report executables" BUILD_ONCE=1 - pushd $BENCHMARK_DIR/bench-report + pushd $BENCH_REPORT_DIR local cmd - cmd="$CABAL_EXECUTABLE install --installdir $SCRIPT_DIR bench-report" + cmd="$CABAL_EXECUTABLE install --installdir bin bench-report" if test "$USE_NIX" -eq 0 then $cmd || die "bench-report build failed" @@ -117,7 +95,6 @@ build_report_prog() { nix-shell --run "$cmd" || die "bench-report build failed" fi popd - elif test ! -x "$prog_path" then return 1 @@ -130,8 +107,8 @@ build_report_progs() { then build_report_prog || exit 1 local prog - prog=$(find_report_prog) || \ - die "Cannot find bench-report executable" + prog=$BENCH_REPORT_DIR/bin/bench-report + test -x $prog || die "Cannot find bench-report executable" echo "Using bench-report executable [$prog]" fi } @@ -426,8 +403,8 @@ run_measurements() { run_reports() { local prog - prog=$(find_report_prog) || \ - die "Cannot find bench-graph executable" + prog=$BENCH_REPORT_DIR/bin/bench-report + test -x $prog || die "Cannot find bench-report executable" echo for i in $1 @@ -445,8 +422,6 @@ run_reports() { # Execution starts here #----------------------------------------------------------------------------- -cd $SCRIPT_DIR/.. - USE_GIT_CABAL=1 # This is used by set_common_vars set_common_vars diff --git a/bin/bench-config.sh b/bin/bench-config.sh index f1fa720f9..cd1dc4753 100644 --- a/bin/bench-config.sh +++ b/bin/bench-config.sh @@ -2,7 +2,7 @@ # Customization options bench_config () { - BENCHMARK_DIR=benchmark + BENCH_REPORT_DIR=benchmark/bench-report BENCHMARK_PACKAGE_NAME=streamly-benchmarks BENCHMARK_PACKAGE_VERSION=0.0.0 diff --git a/bin/bench.sh b/bin/bench.sh index 359563b53..72da4eff5 100755 --- a/bin/bench.sh +++ b/bin/bench.sh @@ -1,3 +1,15 @@ #!/usr/bin/env bash -bin/bench-runner.sh --config bin/bench-config.sh "$@" +SCRIPT_DIR=$(cd `dirname $0`; pwd) +source $SCRIPT_DIR/bench-config.sh \ + || { echo "Cannot source $SCRIPT_DIR/bench-config.sh"; exit 1; } + +bench_config +if test -z "$BENCH_REPORT_DIR" +then + echo "BENCH_REPORT_DIR variable not defined by bench-config() in $SCRIPT_DIR/bench-config.sh" + exit 1 +fi + +cd $SCRIPT_DIR/.. +$BENCH_REPORT_DIR/bin/bench-runner.sh --config $SCRIPT_DIR/bench-config.sh "$@" diff --git a/streamly.cabal b/streamly.cabal index c0cf38a7a..f9066dd8a 100644 --- a/streamly.cabal +++ b/streamly.cabal @@ -62,6 +62,8 @@ extra-source-files: benchmark/README.md benchmark/bench-report/BenchReport.hs benchmark/bench-report/bench-report.cabal + benchmark/bench-report/bin/bench-runner.sh + benchmark/bench-report/bin/build-lib.sh benchmark/bench-report/cabal.project benchmark/bench-report/default.nix benchmark/Streamly/Benchmark/Data/*.hs @@ -78,8 +80,6 @@ extra-source-files: benchmark/streamly-benchmarks.cabal bin/bench.sh bin/bench-config.sh - bin/bench-runner.sh - bin/build-lib.sh bin/ghc.sh bin/run-ci.sh bin/mk-hscope.sh