You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/main-cicd.yml
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -50,15 +50,16 @@ jobs:
50
50
uses: actions/setup-go@v5
51
51
with:
52
52
go-version: "1.24.13"
53
-
- name: Run benchmark suites
53
+
- name: Run benchmark suites with trend report
54
54
run: |
55
-
mkdir -p /tmp/bench
56
-
go test -run '^$' -bench "BenchmarkScanText|BenchmarkPolicyEvaluate|BenchmarkDecideEndpoint|BenchmarkScanEndpoint" -benchmem ./internal/scan ./internal/policy ./internal/server | tee /tmp/bench/benchmark.txt
7. Optional benchmark sweep: `scripts/run-benchmarks.sh`(writes `/tmp/bench/benchmark-current.txt`; if `scripts/benchmark-baseline.txt` exists, also writes `/tmp/bench/benchmark-trend.txt` with benchstat deltas)
go test -run '^$' -bench "$BENCH_PATTERN" -benchmem ./internal/scan ./internal/policy ./internal/server | tee "$CURRENT_FILE"
15
+
16
+
echo"Benchmark output written to $CURRENT_FILE"
17
+
18
+
if [ -f"$BASELINE_FILE" ];then
19
+
echo"Comparing against baseline: $BASELINE_FILE"
20
+
21
+
BENCHSTAT_BIN=""
22
+
ifcommand -v benchstat >/dev/null 2>&1;then
23
+
BENCHSTAT_BIN="$(command -v benchstat)"
24
+
else
25
+
if! go install golang.org/x/perf/cmd/benchstat@latest >/dev/null;then
26
+
echo"warn: unable to install benchstat; skipping trend report"
27
+
exit 0
28
+
fi
6
29
7
-
go test -run '^$' -bench 'BenchmarkScanText|BenchmarkPolicyEvaluate|BenchmarkDecideEndpoint|BenchmarkScanEndpoint' -benchmem ./internal/scan ./internal/policy ./internal/server | tee /tmp/benchmark-results.txt
30
+
GO_BIN="$(go env GOPATH)/bin/benchstat"
31
+
if [ -x"$GO_BIN" ];then
32
+
BENCHSTAT_BIN="$GO_BIN"
33
+
else
34
+
echo"warn: benchstat not available after installation; skipping trend report"
35
+
exit 0
36
+
fi
37
+
fi
8
38
9
-
echo"Benchmark output written to /tmp/benchmark-results.txt"
39
+
"$BENCHSTAT_BIN""$BASELINE_FILE""$CURRENT_FILE"| tee "$TREND_FILE"
40
+
echo"Trend report written to $TREND_FILE"
41
+
else
42
+
echo"No baseline found at $BASELINE_FILE, skipping trend comparison"
0 commit comments