-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbench
executable file
·39 lines (31 loc) · 1.27 KB
/
bench
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
command -v hyperfine > /dev/null || (echo "You need to install 'hyperfine' with cargo or brew." && exit 1)
if [[ -z "$1" ]]; then
mkdir -p logs
test -e logs/example.log.gz || curl -Lo logs/example.log.gz "https://github.com/rubytogether/kirby/releases/download/log-sample/example.log.gz"
LOG="logs/example.log.gz"
else
LOG="$1"
shift
fi
if [[ -n "$PGO" ]]; then
# STEP 0: Make sure there is no left-over profiling data from previous runs
rm -rf /tmp/pgo-data
# STEP 1: Build the instrumented binaries
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data -Cllvm-args=-vp-counters-per-site=4" \
cargo build --release
# STEP 2: Run the instrumented binaries with some typical data
ls logs/* | xargs -L1 target/release/kirby
# STEP 3: Merge the `.profraw` files into a `.profdata` file
$(ls ~/.rustup/toolchains/*/lib/rustlib/*/bin/llvm-profdata) \
merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data
# STEP 4: Use the `.profdata` file for guiding optimizations
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \
cargo build --release --bin kirby
else
cargo build --bin kirby --release
fi
echo
echo "kirby commit $(git log -1 --pretty=format:%H)"
echo "$(gzcat $LOG | wc -l) records total"
hyperfine --warmup 3 "target/release/kirby $LOG" "$@"