From 7da9ffcb6b93263736259f3b9b6c2f9475365f26 Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 29 Apr 2026 10:33:15 +0800 Subject: [PATCH] =?UTF-8?q?chore(bench):=20=E6=89=A9=E5=B1=95=20Makefile?= =?UTF-8?q?=20=E5=9F=BA=E5=87=86=E6=B5=8B=E8=AF=95=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - bench 目标输出到 bench-results.txt,count=5 采样 - 添加 bench-regression 目标,使用阈值配置检测回归 Co-Authored-By: Claude Opus 4.7 --- Makefile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 662cbac..6ed40fc 100644 --- a/Makefile +++ b/Makefile @@ -210,10 +210,10 @@ act-unit: exit 1; \ fi -# 运行基准测试 +# 运行基准测试(输出到文件) bench: @echo "Running benchmarks..." - go test -bench=. -benchmem ./... + go test -bench=. -benchmem -count=5 ./... 2>&1 | tee bench-results.txt # 运行基准测试(统计模式,10次采样) bench-stat: @@ -416,3 +416,20 @@ help: @echo " make install - Install to GOPATH/bin" @echo " make clean - Clean build artifacts" @echo "" + +# 回归检测(使用阈值配置文件) +bench-regression: + @echo "Detecting performance regressions with thresholds..." + @if [ ! -f .benchmark-thresholds.yaml ]; then \ + echo "阈值配置文件不存在: .benchmark-thresholds.yaml"; \ + exit 1; \ + fi + @if [ -f bench-old.txt ] && [ -f bench-new.txt ]; then \ + benchstat bench-old.txt bench-new.txt | python3 scripts/check_regression.py - --config .benchmark-thresholds.yaml; \ + elif [ -f benchmark-baseline.txt ] && [ -f benchmark-current.txt ]; then \ + benchstat benchmark-baseline.txt benchmark-current.txt | python3 scripts/check_regression.py - --config .benchmark-thresholds.yaml; \ + else \ + echo "需要 bench-old.txt 和 bench-new.txt 或 baseline/current 文件"; \ + echo "运行: make bench-stat && mv benchmark-current.txt bench-old.txt && make bench-stat && mv benchmark-current.txt bench-new.txt"; \ + exit 1; \ + fi