File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
+ set -euo pipefail
2
3
3
4
command -v hyperfine > /dev/null || (echo " You need to install 'hyperfine' with cargo or brew." && exit 1)
4
5
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
6
10
mkdir -p logs
7
11
test -e logs/example.log.gz || curl -Lo logs/example.log.gz " https://github.com/rubytogether/kirby/releases/download/log-sample/example.log.gz"
8
12
LOG=" logs/example.log.gz"
11
15
shift
12
16
fi
13
17
14
- if [[ -n " $PGO " ]]; then
18
+ if [[ -n " ${ PGO:- } " ]]; then
15
19
# STEP 0: Make sure there is no left-over profiling data from previous runs
16
20
rm -rf /tmp/pgo-data
21
+ cargo clean
17
22
18
23
# STEP 1: Build the instrumented binaries
19
24
RUSTFLAGS=" -Cprofile-generate=/tmp/pgo-data -Cllvm-args=-vp-counters-per-site=4" \
@@ -23,8 +28,7 @@ if [[ -n "$PGO" ]]; then
23
28
ls logs/* | xargs -L1 target/release/kirby
24
29
25
30
# 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
28
32
29
33
# STEP 4: Use the `.profdata` file for guiding optimizations
30
34
RUSTFLAGS=" -Cprofile-use=/tmp/pgo-data/merged.profdata" \
You can’t perform that action at this time.
0 commit comments