-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add codspeed benchmarks tracking to compare performance changes (…
- Loading branch information
Showing
14 changed files
with
14,974 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: codspeed-benchmarks | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" # or "master" | ||
pull_request: | ||
# `workflow_dispatch` allows CodSpeed to trigger backtest | ||
# performance analysis in order to generate initial data. | ||
workflow_dispatch: | ||
|
||
jobs: | ||
benchmarks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: "actions/checkout@v4" | ||
- uses: "actions/setup-node@v4" | ||
with: | ||
node-version: 20 | ||
- run: corepack enable | ||
- run: pnpm --version | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
cache-dependency-path: "**/pnpm-lock.yaml" | ||
- name: install | ||
run: pnpm install --frozen-lockfile --prefer-offline | ||
- name: Run benchmarks | ||
uses: CodSpeedHQ/action@v2 | ||
with: | ||
run: pnpm run test:bench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { describe, bench } from "vitest"; | ||
import { createAPIClient, createAdminAPIClient } from ".."; | ||
|
||
describe("apiClient benchmarks", () => { | ||
bench("[api-client][createAPIClient] - creating client", async () => { | ||
createAPIClient({ | ||
baseURL: "https://example.com", | ||
accessToken: "123", | ||
}); | ||
}); | ||
|
||
bench("[api-client][createAdminAPIClient] - creating client", async () => { | ||
createAdminAPIClient({ | ||
baseURL: "https://example.com", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { describe, bench, vi } from "vitest"; | ||
import { generate } from "../src/commands/generate"; | ||
import { readFileSync, writeFileSync, existsSync } from "node:fs"; | ||
import testSchema from "./testSchema.json"; | ||
|
||
vi.mock("node:fs", async () => { | ||
return { | ||
writeFileSync: vi.fn(), | ||
existsSync: vi.fn(), | ||
readFileSync: vi.fn(), | ||
}; | ||
}); | ||
// TODO: mocking prettier for more acurate tests, but it should be replaced | ||
vi.mock("prettier", async () => { | ||
return { | ||
format: vi.fn().mockImplementation((content) => content), | ||
}; | ||
}); | ||
vi.mocked(writeFileSync).mockReturnValue(); | ||
vi.mocked(existsSync).mockReturnValue(true); | ||
vi.mocked(readFileSync).mockReturnValue(JSON.stringify(testSchema)); | ||
const consoleWarnSpy = vi.spyOn(console, "log"); | ||
consoleWarnSpy.mockImplementation(() => {}); | ||
|
||
describe("api-gen - generate", () => { | ||
bench("[api-gen][generate] - generate schema command", async () => { | ||
await generate({ | ||
cwd: __dirname, | ||
filename: "testSchema.json", | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.