Skip to content

Commit 89a6766

Browse files
committed
Bench wf
1 parent fcc99e1 commit 89a6766

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/bench.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
workflow_dispatch:
3+
on:
4+
issue_comment:
5+
types: [ created ]
6+
7+
jobs:
8+
bench:
9+
runs-on: ubuntu-latest
10+
if: github.event_name == 'workflow_dispatch' || (github.event.issue.pull_request && contains(github.event.comment.body, '!bench'))
11+
steps:
12+
- name: Set up Go
13+
uses: actions/setup-go@v3
14+
with:
15+
go-version: 1.19
16+
check-latest: true
17+
cache: true
18+
19+
- name: Start Redis
20+
uses: shogo82148/actions-setup-redis@v1
21+
with:
22+
auto-start: true
23+
redis-port: 6379
24+
redis-version: '6.2'
25+
redis-conf: 'requirepass RedisPassw0rd'
26+
27+
- name: Start MySQL
28+
run: sudo /etc/init.d/mysql start
29+
30+
- name: Install Hyperfine
31+
run: |
32+
wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
33+
sudo dpkg -i hyperfine_1.11.0_amd64.deb
34+
35+
- name: Get PR SHA
36+
if: github.event_name == 'issue_comment'
37+
id: sha
38+
uses: actions/github-script@v6
39+
with:
40+
result-encoding: string
41+
script: |
42+
const response = await github.request(context.payload.issue.pull_request.url);
43+
return response.data.head.sha;
44+
45+
- name: Checkout PR
46+
uses: actions/checkout@v2
47+
with:
48+
ref: ${{ steps.sha.outputs.result || github.sha }}
49+
50+
- name: Build PR
51+
run: |
52+
go build -o bench-pr ./bench
53+
54+
- name: Checkout main branch
55+
uses: actions/checkout@v3
56+
with:
57+
clean: false
58+
ref: main
59+
60+
- name: Build main
61+
run: |
62+
go build -o bench-main ./bench
63+
64+
- name: Run benchmarks - mysql
65+
run: |
66+
hyperfine --warmup 1 --export-markdown bench-mysql.md -n 'mysql-main' './bench-main -runs 2' -n 'mysql-pr' './bench-pr -runs 2'
67+
hyperfine --warmup 1 --export-markdown bench-sqlite.md -n 'sqlite-main' './bench-main -runs 2' -n 'sqlite-pr' './bench-pr -runs 2'
68+
hyperfine --warmup 1 --export-markdown bench-redis.md -n 'redis-main' './bench-main -runs 2' -n 'redis-pr' './bench-pr -runs 2'
69+
cat bench-mysql.md > benchmark.md
70+
echo $'\n' >> benchmark.md
71+
cat bench-sqlite.md >> benchmark.md
72+
echo $'\n' >> benchmark.md
73+
cat bench-redis.md >> benchmark.md
74+
75+
- name: Write a new comment
76+
uses: peter-evans/create-or-update-comment@v2
77+
continue-on-error: true
78+
with:
79+
issue-number: ${{ github.event.issue.number }}
80+
body-file: ./benchmark.md

0 commit comments

Comments
 (0)