Skip to content

Commit e976b0a

Browse files
committed
feat: add codspeed benchmarks to the CI
1 parent b9971c7 commit e976b0a

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,25 @@ jobs:
1919
node-version-file: ".nvmrc"
2020
- run: pnpm install --frozen-lockfile --prefer-offline
2121
- run: pnpm moon check --all
22+
23+
codspeed:
24+
runs-on: "ubuntu-latest"
25+
steps:
26+
- uses: "actions/checkout@v3"
27+
- run: sudo apt-get install -y valgrind
28+
- uses: pnpm/[email protected]
29+
with:
30+
version: latest
31+
- uses: "actions/setup-node@v3"
32+
with:
33+
cache: "pnpm"
34+
node-version-file: ".nvmrc"
35+
- run: pnpm install --frozen-lockfile --prefer-offline
36+
- run: pnpm moon run :build
37+
38+
- name: Run benchmarks
39+
uses: CodSpeedHQ/action@v1
40+
with:
41+
token: ${{ secrets.CODSPEED_TOKEN }}
42+
run: pnpm moon run :bench
43+
upload_url: https://api.staging.preview.codspeed.io/upload

packages/benchmark.js/moon.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tasks:
2+
bench:
3+
command: ts-node benches/sample.ts
4+
inputs:
5+
- "benches/**"
6+
local: true
7+
options:
8+
cache: false

packages/tinybench/benches/sample.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ bench
1919
a = b - a;
2020
});
2121

22-
await bench.run();
23-
24-
console.table(
25-
bench.tasks.map(({ name, result }) => ({
26-
"Task Name": name,
27-
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
28-
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
29-
}))
30-
);
22+
bench.run().then(() => {
23+
console.table(
24+
bench.tasks.map(({ name, result }) => ({
25+
"Task Name": name,
26+
"Average Time (ps)": result?.mean ? result.mean * 1000 : "N/A",
27+
"Variance (ps)": result?.variance ? result.variance * 1000 : "N/A",
28+
}))
29+
);
30+
});

packages/tinybench/moon.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tasks:
2+
bench:
3+
command: ts-node benches/sample.ts
4+
inputs:
5+
- "benches/**"
6+
local: true
7+
options:
8+
cache: false

tsconfig.base.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"compilerOptions": {
33
"composite": true,
44
"moduleResolution": "node",
5-
"target": "es6",
6-
"module": "CommonJS",
5+
"target": "ESNext",
6+
"module": "NodeNext",
77
"lib": ["esnext"],
88
"types": ["node"],
99
"strict": true,
@@ -12,7 +12,6 @@
1212
"sourceMap": true,
1313
"emitDecoratorMetadata": true,
1414
"skipLibCheck": true,
15-
"allowJs": true,
1615
"forceConsistentCasingInFileNames": true,
1716
"esModuleInterop": true,
1817
"resolveJsonModule": true,

0 commit comments

Comments
 (0)