3
3
4
4
declare -A PKGS=(
5
5
[" strconv" ]=" strconv"
6
+ [" net/http" ]=" net/http"
7
+ [" image/color" ]=" image/color"
6
8
[" std" ]=" std"
7
9
[" k8s" ]=" k8s.io/kubernetes/pkg/..."
8
10
)
9
11
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
13
16
MAX_GOGC=100
14
- SAMPLES=5
17
+ SAMPLES=10
15
18
WIPE_CACHE=1
16
- FORMAT=csv
19
+ FORMAT=bench
17
20
BIN=$( realpath ./silent-staticcheck.sh)
18
- SMT=1
19
-
20
21
21
22
runBenchmark () {
22
23
local pkg=" $1 "
@@ -29,40 +30,32 @@ runBenchmark() {
29
30
rm -rf ~ /.cache/staticcheck
30
31
fi
31
32
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 )
40
34
local t=$( echo " $out " | cut -f1 -d" " )
41
35
local m=$( echo " $out " | cut -f2 -d" " )
42
36
local ns=$( printf " %s 1000000000 * p" $t | dc)
43
37
local b=$(( m * 1024 ))
44
38
45
39
case $FORMAT in
46
40
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 "
48
42
;;
49
43
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 "
51
45
;;
52
46
esac
53
47
}
54
48
55
- go build ../cmd/staticcheck
56
49
export GO111MODULE=off
57
50
58
51
if [ " $FORMAT " = " csv" ]; then
59
- printf " packages,gogc,procs ,wipe-cache,time,memory\n"
52
+ printf " packages,gogc,gomaxprocs ,wipe-cache,time,memory\n"
60
53
fi
61
54
62
55
for label in " ${! PKGS[@]} " ; do
63
56
pkg=${PKGS[$label]}
64
57
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
66
59
for i in $( seq 1 $SAMPLES ) ; do
67
60
runBenchmark " $pkg " " $label " " $gc " " $cores " 1
68
61
runBenchmark " $pkg " " $label " " $gc " " $cores " 0
0 commit comments