Skip to content

Commit 5f2e4ea

Browse files
authored
Merge pull request #70 from gadget-inc/codspeed
Add codspeed continuous benchmarking for CI
2 parents 8e7dd8c + d60267e commit 5f2e4ea

File tree

5 files changed

+93
-12
lines changed

5 files changed

+93
-12
lines changed

.github/workflows/benchmark.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Benchmark"
2+
on:
3+
push:
4+
workflow_call:
5+
workflow_dispatch:
6+
jobs:
7+
bench:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/[email protected]
11+
- uses: ./.github/actions/setup-test-env
12+
- name: Run benchmarks
13+
uses: CodSpeedHQ/action@v1
14+
with:
15+
run: pnpm x bench/all.ts
16+
token: ${{ secrets.CODSPEED_TOKEN }}

.github/workflows/test.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ jobs:
2121
shell: bash
2222
run: pnpm lint
2323

24-
bench:
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/[email protected]
28-
- uses: ./.github/actions/setup-test-env
29-
- name: Run benchmarks
30-
shell: bash
31-
run: pnpm x bench/all.ts
32-
3324
build-js:
3425
runs-on: ubuntu-latest
3526
steps:

bench/all.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { Suite } from "benchmark";
2+
import { withCodSpeed } from "@codspeed/benchmark.js-plugin";
23
import findRoot from "find-root";
34
import fs from "fs";
45
import { LargeRoot } from "../spec/fixtures/LargeRoot";
56
import { FruitAisle } from "../spec/fixtures/FruitAisle";
67
import { TestClassModel } from "../spec/fixtures/TestClassModel";
7-
import { TestModelSnapshot } from "../spec/fixtures/TestModel";
8+
import { BigTestModelSnapshot, TestModelSnapshot } from "../spec/fixtures/TestModel";
89

910
const root = findRoot(__dirname);
1011
const largeRoot = JSON.parse(fs.readFileSync(root + "/spec/fixtures/large-root-snapshot.json", "utf8"));
1112
const fruitAisle = JSON.parse(fs.readFileSync(root + "/spec/fixtures/fruit-aisle-snapshot.json", "utf8"));
12-
const suite = new Suite("instantiating model classes");
13+
const suite = withCodSpeed(new Suite("instantiating model classes"));
1314

14-
suite
15+
void suite
1516
.add("instantiating a small root", function () {
1617
TestClassModel.createReadOnly(TestModelSnapshot);
1718
})
@@ -21,6 +22,9 @@ suite
2122
.add("instantiating a large union", function () {
2223
FruitAisle.createReadOnly(fruitAisle);
2324
})
25+
.add("instantiating a diverse root", function () {
26+
TestClassModel.createReadOnly(BigTestModelSnapshot);
27+
})
2428
.on("start", function () {
2529
console.profile();
2630
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"reflect-metadata": "^0.1.13"
3333
},
3434
"devDependencies": {
35+
"@codspeed/benchmark.js-plugin": "^2.2.0",
3536
"@faker-js/faker": "^7.6.0",
3637
"@gadgetinc/eslint-config": "^0.6.1",
3738
"@gadgetinc/prettier-config": "^0.4.0",

pnpm-lock.yaml

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)