fix duplicated benchmark name problem

pull/3220/head
René 2024-12-01 15:14:32 +01:00
parent 77622700d7
commit 689537a0d2
1 changed files with 29 additions and 0 deletions

View File

@ -35,6 +35,35 @@ jobs:
- name: Run Benchmark
run: set -o pipefail; go test ./... -benchmem -run=^$ -bench . | tee output.txt
### hack because of the problem with duplicated benchmark names - https://github.com/benchmark-action/github-action-benchmark/issues/264
- name: Extract Module Name
id: extract-module
run: |
MODULE_NAME=$(awk '/^module / {print $2}' go.mod)
echo "MODULE_NAME=$MODULE_NAME" >> $GITHUB_ENV
- name: Identify Duplicate Benchmark Names
run: |
awk '/^Benchmark/ {print $1}' output.txt | sort | uniq -d > duplicate_benchmarks.txt
- name: Add Normalized Package Prefix to Duplicate Benchmark Names
run: |
awk -v MODULE_NAME="$MODULE_NAME" '
FNR==NR {duplicates[$1]; next}
/^pkg: / { package=$2 }
/^Benchmark/ {
if ($1 in duplicates) {
sub("^" MODULE_NAME "/?", "", package)
gsub("/", "_", package)
print $1 "_" package substr($0, length($1) + 1)
} else {
print $0
}
next
}
{ print }
' duplicate_benchmarks.txt output.txt > output.txt
### end
# NOTE: Benchmarks could change with different CPU types
- name: Get GitHub Runner System Information