Skip to content

Commit 93b3491

Browse files
authored
improve benchmark (#636)
1 parent 827eeb8 commit 93b3491

File tree

2 files changed

+12
-56
lines changed

2 files changed

+12
-56
lines changed

.github/workflows/benchmark.yml

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Benchmark
1+
name: Benchmark PR
22

33
on:
44
pull_request_target:
@@ -11,17 +11,8 @@ jobs:
1111
permissions:
1212
contents: read
1313
outputs:
14-
PR-BENCH-14: ${{ steps.benchmark-pr.outputs.BENCH_RESULT14 }}
15-
PR-BENCH-16: ${{ steps.benchmark-pr.outputs.BENCH_RESULT16 }}
16-
PR-BENCH-18: ${{ steps.benchmark-pr.outputs.BENCH_RESULT18 }}
17-
PR-BENCH-20: ${{ steps.benchmark-pr.outputs.BENCH_RESULT20 }}
18-
MASTER-BENCH-14: ${{ steps.benchmark-master.outputs.BENCH_RESULT14 }}
19-
MASTER-BENCH-16: ${{ steps.benchmark-master.outputs.BENCH_RESULT16 }}
20-
MASTER-BENCH-18: ${{ steps.benchmark-master.outputs.BENCH_RESULT18 }}
21-
MASTER-BENCH-20: ${{ steps.benchmark-master.outputs.BENCH_RESULT20 }}
22-
strategy:
23-
matrix:
24-
node-version: [14, 16, 18, 20]
14+
PR-BENCH: ${{ steps.benchmark-pr.outputs.BENCH_RESULT }}
15+
MASTER-BENCH: ${{ steps.benchmark-master.outputs.BENCH_RESULT }}
2516
steps:
2617
- uses: actions/checkout@v3
2718
with:
@@ -31,7 +22,7 @@ jobs:
3122

3223
- uses: actions/setup-node@v3
3324
with:
34-
node-version: ${{ matrix.node-version }}
25+
node-version: 18
3526

3627
- name: Install
3728
run: |
@@ -40,12 +31,12 @@ jobs:
4031
- name: Run benchmark
4132
id: benchmark-pr
4233
run: |
43-
npm run --silent benchmark > ./bench-result
34+
npm run --silent bench > ./bench-result
4435
content=$(cat ./bench-result)
4536
content="${content//'%'/'%25'}"
4637
content="${content//$'\n'/'%0A'}"
4738
content="${content//$'\r'/'%0D'}"
48-
echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$content"
39+
echo "::set-output name=BENCH_RESULT::$content"
4940
5041
# master benchmark
5142
- uses: actions/checkout@v3
@@ -59,14 +50,15 @@ jobs:
5950
- name: Run benchmark
6051
id: benchmark-master
6152
run: |
62-
npm run --silent benchmark > ./bench-result
53+
npm run --silent bench > ./bench-result
6354
content=$(cat ./bench-result)
6455
content="${content//'%'/'%25'}"
6556
content="${content//$'\n'/'%0A'}"
6657
content="${content//$'\r'/'%0D'}"
67-
echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$content"
58+
echo "::set-output name=BENCH_RESULT::$content"
6859
6960
output-benchmark:
61+
if: "always()"
7062
needs: [benchmark]
7163
runs-on: ubuntu-latest
7264
permissions:
@@ -77,49 +69,13 @@ jobs:
7769
with:
7870
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7971
message: |
80-
**Node**: 14
8172
**PR**:
8273
```
83-
${{ needs.benchmark.outputs.PR-BENCH-14 }}
74+
${{ needs.benchmark.outputs.PR-BENCH }}
8475
```
8576
**MASTER**:
8677
```
87-
${{ needs.benchmark.outputs.MASTER-BENCH-14 }}
88-
```
89-
90-
---
91-
92-
**Node**: 16
93-
**PR**:
94-
```
95-
${{ needs.benchmark.outputs.PR-BENCH-16 }}
96-
```
97-
**MASTER**:
98-
```
99-
${{ needs.benchmark.outputs.MASTER-BENCH-16 }}
100-
```
101-
102-
---
103-
104-
**Node**: 18
105-
**PR**:
106-
```
107-
${{ needs.benchmark.outputs.PR-BENCH-18 }}
108-
```
109-
**MASTER**:
110-
```
111-
${{ needs.benchmark.outputs.MASTER-BENCH-18 }}
112-
113-
---
114-
115-
**Node**: 20
116-
**PR**:
117-
```
118-
${{ needs.benchmark.outputs.PR-BENCH-20 }}
119-
```
120-
**MASTER**:
121-
```
122-
${{ needs.benchmark.outputs.MASTER-BENCH-20 }}
78+
${{ needs.benchmark.outputs.MASTER-BENCH }}
12379
```
12480
12581
- uses: actions-ecosystem/action-remove-labels@v1

benchmark/bench-thread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const { workerData: benchmark, parentPort } = require('worker_threads')
44

55
const Benchmark = require('benchmark')
6-
Benchmark.options.minSamples = 500
6+
Benchmark.options.minSamples = 100
77

88
const suite = Benchmark.Suite()
99

0 commit comments

Comments
 (0)