-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (50 loc) · 1.55 KB
/
benchmark.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Benchmark
on:
pull_request:
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run benchmark
run: |
mkdir -p ./profile
{
echo "stdout<<EOF"
go test -short -benchmem -bench . -cpuprofile ./profile/cpu.out -memprofile ./profile/mem.out
echo "EOF"
} >> $GITHUB_OUTPUT
id: bench
- uses: actions/upload-artifact@v4
id: artifact
with:
name: profile
path: profile
- name: Comment
run: |
cat << EOF > ./body.txt
## Benchmark Result
\`\`\`text
${{ steps.bench.outputs.stdout }}
\`\`\`
<details>
<summary>pprof command</summary>
\`\`\`sh
gh api /repos/${{ github.repository }}/actions/artifacts/${{ steps.artifact.outputs.artifact-id }}/zip > /tmp/profile.zip
unzip /tmp/profile.zip -d profile
rm -rf /tmp/profile.zip
go tool pprof -http :6060 profile/cpu.out
\`\`\`
</details>
EOF
gh pr comment ${{ github.event.pull_request.number }} --edit-last -F ./body.txt --repo ${{ github.repository }} ||
gh pr comment ${{ github.event.pull_request.number }} -F ./body.txt --repo ${{ github.repository }}
env:
GH_TOKEN: ${{ github.token }}