Skip to content

Commit 911c788

Browse files
committed
Tweaks to our benchmarking script
1 parent c13dc1b commit 911c788

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

_benchmarks/bench.sh

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ set -e
33

44
declare -A PKGS=(
55
["strconv"]="strconv"
6+
["net/http"]="net/http"
7+
["image/color"]="image/color"
68
["std"]="std"
79
["k8s"]="k8s.io/kubernetes/pkg/..."
810
)
911

10-
MIN_CORES=1
11-
MAX_CORES=16
12-
MIN_GOGC=10
12+
MIN_CORES=32
13+
MAX_CORES=32
14+
INCR_CORES=2
15+
MIN_GOGC=100
1316
MAX_GOGC=100
14-
SAMPLES=5
17+
SAMPLES=10
1518
WIPE_CACHE=1
16-
FORMAT=csv
19+
FORMAT=bench
1720
BIN=$(realpath ./silent-staticcheck.sh)
18-
SMT=1
19-
2021

2122
runBenchmark() {
2223
local pkg="$1"
@@ -29,40 +30,32 @@ runBenchmark() {
2930
rm -rf ~/.cache/staticcheck
3031
fi
3132

32-
local procs
33-
if [ $SMT -ne 0 ]; then
34-
procs=$((cores*2))
35-
else
36-
procs=$cores
37-
fi
38-
39-
local out=$(GOGC=$gc env time -f "%e %M" taskset -c 0-$((procs-1)) $BIN $pkg 2>&1)
33+
local out=$(GOGC=$gc GOMAXPROCS=$cores env time -f "%e %M" $BIN $pkg 2>&1)
4034
local t=$(echo "$out" | cut -f1 -d" ")
4135
local m=$(echo "$out" | cut -f2 -d" ")
4236
local ns=$(printf "%s 1000000000 * p" $t | dc)
4337
local b=$((m * 1024))
4438

4539
case $FORMAT in
4640
bench)
47-
printf "BenchmarkStaticcheck-%s-GOGC%d-wiped%d-%d 1 %.0f ns/op %.0f B/op\n" "$label" "$gc" "$wipe" "$procs" "$ns" "$b"
41+
printf "BenchmarkStaticcheck-%s-GOGC%d-wiped%d-%d 1 %.0f ns/op %.0f B/op\n" "$label" "$gc" "$wipe" "$cores" "$ns" "$b"
4842
;;
4943
csv)
50-
printf "%s,%d,%d,%d,%.0f,%.0f\n" "$label" "$gc" "$procs" "$wipe" "$ns" "$b"
44+
printf "%s,%d,%d,%d,%.0f,%.0f\n" "$label" "$gc" "$cores" "$wipe" "$ns" "$b"
5145
;;
5246
esac
5347
}
5448

55-
go build ../cmd/staticcheck
5649
export GO111MODULE=off
5750

5851
if [ "$FORMAT" = "csv" ]; then
59-
printf "packages,gogc,procs,wipe-cache,time,memory\n"
52+
printf "packages,gogc,gomaxprocs,wipe-cache,time,memory\n"
6053
fi
6154

6255
for label in "${!PKGS[@]}"; do
6356
pkg=${PKGS[$label]}
6457
for gc in $(seq $MIN_GOGC 10 $MAX_GOGC); do
65-
for cores in $(seq $MIN_CORES $MAX_CORES); do
58+
for cores in $(seq $MIN_CORES $INCR_CORES $MAX_CORES); do
6659
for i in $(seq 1 $SAMPLES); do
6760
runBenchmark "$pkg" "$label" "$gc" "$cores" 1
6861
runBenchmark "$pkg" "$label" "$gc" "$cores" 0

0 commit comments

Comments
 (0)