10
10
# Benchmark results are saved with filenames based on the branch name.
11
11
#
12
12
# Usage:
13
- # benchmark_authz.sh --single # Run benchmarks on current branch
14
- # benchmark_authz.sh --compare <branchA> <branchB> # Compare benchmarks between two branches
13
+ # benchmark_authz.sh --single # Run benchmarks on current branch
14
+ # benchmark_authz.sh --compare <branchA> <branchB> # Compare benchmarks between two branches
15
15
16
16
set -euo pipefail
17
17
@@ -22,7 +22,8 @@ BENCHTIME=5s
22
22
COUNT=5
23
23
24
24
# Script configuration
25
- OUTPUT_DIR=" benchmark_outputs"
25
+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
26
+ OUTPUT_DIR=" ${SCRIPT_DIR} /benchmark_outputs"
26
27
27
28
# List of benchmark tests
28
29
BENCHMARKS=(
@@ -43,14 +44,20 @@ function run_benchmarks() {
43
44
echo " Checking out $branch ..."
44
45
git checkout " $branch "
45
46
47
+ # Move into the rbac directory to run the benchmark tests
48
+ pushd ../../coderd/rbac/ > /dev/null
49
+
46
50
for bench in " ${BENCHMARKS[@]} " ; do
47
51
local output_file=" ${output_file_prefix} _${bench} .txt"
48
52
echo " Running benchmark $bench on $branch ..."
49
53
GOMAXPROCS=$GOMAXPROCS go test -timeout $TIMEOUT -bench=" ^${bench} $" -run=^$ -benchtime=$BENCHTIME -count=$COUNT | tee " $output_file "
50
54
done
55
+
56
+ # Return to original directory
57
+ popd > /dev/null
51
58
}
52
59
53
- if [[ " ${1:- } " == " --single" ]]; then
60
+ if [[ $# -eq 0 || " ${1:- } " == " --single" ]]; then
54
61
current_branch=$( git rev-parse --abbrev-ref HEAD)
55
62
run_benchmarks " $current_branch "
56
63
elif [[ " ${1:- } " == " --compare" ]]; then
@@ -72,7 +79,7 @@ elif [[ "${1:-}" == "--compare" ]]; then
72
79
done
73
80
else
74
81
echo " Usage:"
75
- echo " $0 --single # run benchmarks on current branch"
76
- echo " $0 --compare branchA branchB # compare benchmarks between two branches"
82
+ echo " $0 --single # run benchmarks on current branch"
83
+ echo " $0 --compare branchA branchB # compare benchmarks between two branches"
77
84
exit 1
78
85
fi
0 commit comments