Skip to content

Commit a8ed8a3

Browse files
committed
update bench to check for llvm tools
1 parent 58ebb3d commit a8ed8a3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bin/bench

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
2+
set -euo pipefail
23

34
command -v hyperfine > /dev/null || (echo "You need to install 'hyperfine' with cargo or brew." && exit 1)
45

5-
if [[ -z "$1" ]]; then
6+
LLVM_PROFDATA="$(ls ~/.rustup/toolchains/*/lib/rustlib/*/bin/llvm-profdata)"
7+
command -v $LLVM_PROFDATA > /dev/null || (echo "You need to install 'llvm-profdata' byrunning 'rustup component add llvm-tools-preview'" && exit 1)
8+
9+
if [[ -z "${1:-}" ]]; then
610
mkdir -p logs
711
test -e logs/example.log.gz || curl -Lo logs/example.log.gz "https://github.com/rubytogether/kirby/releases/download/log-sample/example.log.gz"
812
LOG="logs/example.log.gz"
@@ -11,9 +15,10 @@ else
1115
shift
1216
fi
1317

14-
if [[ -n "$PGO" ]]; then
18+
if [[ -n "${PGO:-}" ]]; then
1519
# STEP 0: Make sure there is no left-over profiling data from previous runs
1620
rm -rf /tmp/pgo-data
21+
cargo clean
1722

1823
# STEP 1: Build the instrumented binaries
1924
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data -Cllvm-args=-vp-counters-per-site=4" \
@@ -23,8 +28,7 @@ if [[ -n "$PGO" ]]; then
2328
ls logs/* | xargs -L1 target/release/kirby
2429

2530
# STEP 3: Merge the `.profraw` files into a `.profdata` file
26-
$(ls ~/.rustup/toolchains/*/lib/rustlib/*/bin/llvm-profdata) \
27-
merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data
31+
$LLVM_PROFDATA merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data
2832

2933
# STEP 4: Use the `.profdata` file for guiding optimizations
3034
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \

0 commit comments

Comments
 (0)