Skip to content

Commit

Permalink
fix duplicated benchmark name problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneWerner87 committed Dec 1, 2024
1 parent 7762270 commit 689537a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 689537a

Please sign in to comment.