-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
252 lines (218 loc) · 8.04 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Benchmark
on:
push:
paths-ignore:
- 'website/**'
branches:
- master
pull_request:
paths-ignore:
- 'website/**'
types: [labeled, synchronize, opened, reopened]
permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write
jobs:
results:
runs-on: ubuntu-latest
needs: benchmark
steps:
- uses: actions/checkout@v2
- run: |
touch results.json
echo '${{ needs.benchmark.outputs.results }}' >> results.json
# gh-pages branch is updated and pushed automatically with extracted benchmark data
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
# This needs access to secersts so only run it on push to master
if: github.event_name == 'push'
with:
name: "Yew master branch benchmarks (Lower is better)"
tool: "customSmallerIsBetter"
output-file-path: results.json
gh-pages-branch: "gh-pages"
# Access token to deploy GitHub Pages branch
github-token: ${{ secrets.GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically
alert-threshold: "200%"
alert-comment-cc-users: "@yewstack/yew"
auto-push: true
save-data-file: true
benchmark:
runs-on: ubuntu-latest
outputs:
results: ${{ steps.results.outputs.stdout }}
steps:
- uses: actions/checkout@v2
with:
path: "./yew"
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: "${{ github.head_ref }}"
- uses: actions/checkout@v2
with:
repository: krausest/js-framework-benchmark
path: "./js-framework-benchmark"
ref: 678cd09a8e02b9a01bcb9b71dc9248d17a33ff82
- name: Setup toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: jetli/wasm-pack-action@v0.4.0
with:
version: "latest"
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16
- uses: Swatinem/rust-cache@v1
with:
working-directory: yew
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-benchmark-${{ hashFiles('js-framework-benchmark/package-lock.json') }}-${{ hashFiles('js-framework-benchmark/webdriver-ts/package-lock.json') }}
restore-keys: |
${{ runner.os }}-benchmark-
${{ runner.os }}
# Optimisation flags has no effect unless set at workspace level.
- name: Write optimisation flags
run: |
cat >> Cargo.toml << EOF
[profile.release]
lto = true
codegen-units = 1
panic = "abort"
EOF
working-directory: yew
- name: save yew-struct setup
shell: bash
run: |
mkdir yew-struct-setup
cp -r js-framework-benchmark/frameworks/keyed/yew/* yew-struct-setup/
cd yew-struct-setup/bundled-dist
rm -rf ./*
# Will be enabled after https://github.com/krausest/js-framework-benchmark/pull/985 gets merged
# - name: save yew-hooks setup
# shell: bash
# run: |
# mkdir yew-hooks-setup
# cp -r js-framework-benchmark/frameworks/keyed/yew-hooks/* yew-hooks-setup/
# cd yew-hooks-setup/bundled-dist
# rm -rf ./*
- name: replace framework version in yew
shell: bash
run: |
replace=" \"frameworkVersion\": \"\""
input=$(cat yew-struct-setup/package.json)
output=$(echo "$input" | sed -e "s@\"frameworkVersion\": .*\"@$replace@g")
if [[ "$input" == "$output" ]]; then
echo "ERROR: failed to configure framework version"
exit 1
fi
echo "$output" > yew-struct-setup/package.json
echo "$output"
# Will be enabled after https://github.com/krausest/js-framework-benchmark/pull/985 gets merged
# - name: replace framework version in yew-hooks
# shell: bash
# run: |
# replace=" \"frameworkVersion\": \"\""
# input=$(cat yew-hooks-setup/package.json)
# output=$(echo "$input" | sed -e "s@\"frameworkVersion\": .*\"@$replace@g")
# if [[ "$input" == "$output" ]]; then
# echo "ERROR: failed to configure framework version"
# exit 1
# fi
# echo "$output" > yew-hooks-setup/package.json
# echo "$output"
- name: delete all frameworks
shell: bash
run: |
cd js-framework-benchmark/frameworks/keyed
rm -rf ./*
cd ../non-keyed
rm -rf ./*
- name: create framework folders
shell: bash
run: |
cd js-framework-benchmark/frameworks/keyed
mkdir yew-struct
# Will be enabled after https://github.com/krausest/js-framework-benchmark/pull/985 gets merged
# mkdir yew-hooks
- name: copy necessary framework files
shell: bash
run: |
cp -r yew-struct-setup/* js-framework-benchmark/frameworks/keyed/yew-struct/
# Will be enabled after https://github.com/krausest/js-framework-benchmark/pull/985 gets merged
# cp -r yew-hooks-setup/* js-framework-benchmark/frameworks/keyed/yew-hooks/
- name: build benchmark-struct app
shell: bash
run: |
cd yew/tools/benchmark-struct
npm ci
npm run build-prod-without-tools-install
- name: build benchmark-hooks app
shell: bash
run: |
cd yew/tools/benchmark-hooks
npm ci
npm run build-prod-without-tools-install
- name: move dist files
shell: bash
run: |
mv yew/tools/benchmark-struct/bundled-dist js-framework-benchmark/frameworks/keyed/yew-struct/
# Will be enabled after https://github.com/krausest/js-framework-benchmark/pull/985 gets merged
# mv yew/tools/benchmark-hooks/bundled-dist js-framework-benchmark/frameworks/keyed/yew-hooks/
- name: js-framework-benchmark npm ci
shell: bash
run: |
cd js-framework-benchmark
npm ci
- name: js-framework-benchmark npm start
shell: bash
run: |
cd js-framework-benchmark
npm start &
- name: js-framework-benchmark/webdriver-ts npm ci
shell: bash
run: |
cd js-framework-benchmark/webdriver-ts
npm ci
npm install chromedriver --chromedriver-force-download
- name: js-framework-benchmark/webdriver-ts npm run compile
shell: bash
run: |
cd js-framework-benchmark/webdriver-ts
npm run compile
- name: js-framework-benchmark npm run build-prod
shell: bash
run: |
cd js-framework-benchmark
npm run build-prod
- name: js-framework-benchmark/webdriver-ts npm run bench
shell: bash
run: |
cd js-framework-benchmark/webdriver-ts
npm run bench -- --headless
- name: transform results into json
shell: bash
run: |
cd js-framework-benchmark/webdriver-ts/results
touch temp.txt
echo "[" >> temp.txt
for filename in *.json; do cat ${filename} >> temp.txt; echo "," >> temp.txt; done
sed -i '$ s/.$//' temp.txt #remove trailing comma
echo "]" >> temp.txt
mv temp.txt results.json
- name: Build process-benchmark-results
shell: bash
run: |
cd yew/tools
cargo build --release -p process-benchmark-results
- name: transform results to be fit for display benchmark-action/github-action-benchmark@v1
uses: mathiasvr/command-output@v1
id: results
with:
run: cat js-framework-benchmark/webdriver-ts/results/results.json | ./yew/tools/target/release/process-benchmark-results