-
Notifications
You must be signed in to change notification settings - Fork 19
50 lines (40 loc) · 1.33 KB
/
benchmark.yml
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
name: Bechmark
on:
pull_request:
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.17
- name: Git clone (master)
uses: actions/checkout@v4
with:
ref: master
- name: Run benchmark (master)
run: go test -bench=. -count=10 -benchmem | tee /tmp/master.txt
- name: Git clone (PR)
uses: actions/checkout@v4
- name: Run benchmark (PR)
run: go test -bench=. -count=10 -benchmem | tee /tmp/pr.txt
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Run benchstat
run: cd /tmp && benchstat master.txt pr.txt | tee /tmp/result.txt
- name: Comment on PR with benchmark results
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const results = fs.readFileSync('/tmp/result.txt', 'utf8');
const issue_number = context.payload.pull_request.number;
const { owner, repo } = context.repo;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: `### Benchmark Results\n\n\`\`\`\n${results}\n\`\`\``
});