File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 6060 run : |
6161 echo -e "\e[34mRunning rust benchmarks on dedicated machine fr1-spm15!\e[0m"
6262
63+ CRITERION_HOME=$(mktemp -d)
64+ trap "rm -rf $CRITERION_HOME" INT TERM EXIT
65+
6366 while IFS= read -r tgt; do
64- bazel run "$tgt"
67+ bazel run "$tgt" -- --criterion-home "$CRITERION_HOME"
6568 done < <(bazel query "attr(tags, 'rust_bench', ${{ matrix.target }})")
6669
6770 while IFS= read -r bench_dir; do
8285 >report.json
8386 curl --fail --retry 2 -sS -o /dev/null -X POST -H 'Content-Type: application/json' --data @report.json \
8487 "https://elasticsearch.testnet.dfinity.network/ci-performance-test/_doc"
85- done < <(find -L ./bazel-out -type d -path '*/new')
88+ done < <(find -L "$CRITERION_HOME" -type d -path '*/new')
8689
8790 echo -e "\e[34mRust benchmarks on dedicated machine fr1-spm15 finished.\e[0m"
Original file line number Diff line number Diff line change 22
33set -euo pipefail
44
5+ # criterion supports specifying a "home" where it places its benchmark result tree.
6+ # at the time of writing, our bazel version (.bazelversion) is outdated and sh_binary
7+ # does not support `env_inherit` so add (or rather intercept) a new CLI argument
8+ # `--criterion-home` which we convert into `CRITERION_HOME`, which is read by
9+ # criterion.rs.
10+ #
11+ # https://github.com/criterion-rs/criterion.rs/blob/950c3b727a09d10067ea686e2ac6f1f23569168f/src/lib.rs#L142-L142
12+
13+ # store passthru args
14+ args=()
15+ while [[ $# -gt 0 ]]; do
16+ case $1 in
17+ --criterion-home)
18+ shift
19+ export CRITERION_HOME=" $1 "
20+ ;;
21+ * )
22+ # passthru
23+ args+=(" $1 " )
24+ shift
25+ ;;
26+ esac
27+ done
28+
529# When Cargo runs benchmarks, it passes the --bench or --test command-line arguments to
630# the benchmark executables. Criterion.rs looks for these arguments and tries to either
731# run benchmarks or run in test mode. In particular, when you run cargo test --benches
@@ -11,7 +35,7 @@ set -euo pipefail
1135# present, or when --bench and --test are both present.
1236#
1337# https://bheisler.github.io/criterion.rs/book/faq.html#when-i-run-benchmark-executables-directly-without-using-cargo-they-just-print-success-why
14- CMD=" ${BAZEL_DEFS_BENCH_PREFIX}${BAZEL_DEFS_BENCH_BIN} --bench $@ "
38+ CMD=" ${BAZEL_DEFS_BENCH_PREFIX}${BAZEL_DEFS_BENCH_BIN} --bench ${args[@]} "
1539
1640echo " running ${CMD} "
1741${CMD}
You can’t perform that action at this time.
0 commit comments