-
Notifications
You must be signed in to change notification settings - Fork 21
115 lines (95 loc) · 3.29 KB
/
micro-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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Micro-Benchmark
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions:
issues: write
pull-requests: write
jobs:
benchmark:
strategy:
matrix:
os: [ubuntu-latest] # `macos-latest` is too unstable to be useful for benchmark, the variance is always huge.
name: Run benchmark on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Main Branch
uses: actions/checkout@v4
with:
ref: main # Checkout main first because the cache is warm
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
shared-key: micro-benchmark
- name: Compile
run: cargo build --release --bin=micro-benchmark
- name: Sleep for CPU cooldown
shell: bash
run: sleep 15s
- name: Run Bench on Main Branch
run: cargo run --bin=micro-benchmark --release -- --save-baseline main
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
clean: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Compile
run: cargo build --release --bin=micro-benchmark
- name: Sleep for CPU cooldown
shell: bash
run: sleep 15s
- name: Run Bench on PR Branch
run: cargo run --bin=micro-benchmark --release -- --save-baseline pr
- name: Upload benchmark results
uses: actions/upload-artifact@v3
with:
name: benchmark-results-${{ matrix.os }}
path: ./target/criterion
benchmark-compare:
runs-on: ubuntu-latest
name: Compare Benchmarks
needs:
- benchmark
steps:
- name: Install critcmp
uses: taiki-e/install-action@v2
with:
tool: critcmp
- name: Linux | Download PR benchmark results
uses: actions/download-artifact@v3
with:
name: benchmark-results-ubuntu-latest
path: ./target/criterion
- name: Linux | Compare benchmark results
shell: bash
run: |
echo "## Micro-Benchmark Results" >> summary.md
echo "### Linux" >> summary.md
echo "\`\`\`" >> summary.md
critcmp main pr >> summary.md
echo "\`\`\`" >> summary.md
echo "" >> summary.md
- name: Linux | Cleanup benchmark results
run: rm -rf ./target/criterion
- name: Find Comment
# Check if the event is not triggered by a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Micro-Benchmark Results
- name: Create or update comment
# Check if the event is not triggered by a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
comment-id: ${{ steps.fc.outputs.comment-id }}
body-file: summary.md