67 lines (57 loc) · 2.08 KB
/
bench.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
57
58
59
60
61
62
63
64
65
66
67
name: Benchmark
on:
issue_comment:
types: [created]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
bench:
name: Bench
runs-on: ubuntu-latest
if: github.event.issue.pull_request && contains(github.event.comment.body, '!bench')
steps:
- name: Checkout Branch
uses: actions/checkout@v4
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
bins: critcmp
- name: Prepare Benchmark
run: |
git clone --branch r108 --depth 1 https://github.com/mrdoob/three.js.git ./temp/three
echo "import * as three from './src/Three.js'; export { three }" > temp/three/entry.js
mkdir -p temp/three10x
for i in {1..10}; do cp -r ./temp/three/src ./temp/three10x/copy$i/; done
echo > temp/three10x/entry.js
for i in {1..10}; do echo "import * as three$i from './copy$i/Three.js'; export { three$i }" >> temp/three10x/entry.js; done
- name: Run Bench on PR Branch
run: cargo bench -p bench -- --save-baseline pr
- name: Checkout Next Branch
uses: actions/checkout@v4
with:
clean: false
ref: main
- name: Run Bench on Main Branch
run: cargo bench -p bench -- --save-baseline baseline
- name: Compare Bench Results
id: bench_comparison
shell: bash
run: |
echo "### Benchmark Results" > output
echo "\`\`\`" >> output
critcmp baseline pr >> output
echo "\`\`\`" >> output
cat output
comment="$(cat output)"
comment="${comment//'%'/%25}"
comment="${comment//$'\n'/%0A}"
comment="${comment//$'\r'/%0D}"
echo "::set-output name=comment::$comment"
- name: Write a new comment
uses: peter-evans/create-or-update-comment@v4.0.0
continue-on-error: true
with:
issue-number: ${{ github.event.issue.number }}
body: |
${{ steps.bench_comparison.outputs.comment }}