Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/client-nav-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
uses: TanStack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main

- name: Run ${{ matrix.benchmark }}:${{ matrix.framework }} CodSpeed benchmark
continue-on-error: true
uses: CodSpeedHQ/action@9d332c4d90b43981c3e55ae8e38e68709996240f # v4.17.0
with:
mode: simulation
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/client-nav/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"private": true,
"type": "module",
"scripts": {
"build:react": "vite build --config ./react/vite.config.ts",
"build:solid": "vite build --config ./solid/vite.config.ts",
"build:vue": "vite build --config ./vue/vite.config.ts",
"build:react": "NODE_ENV=production vite build --config ./react/vite.config.ts",
"build:solid": "NODE_ENV=production vite build --config ./solid/vite.config.ts",
"build:vue": "NODE_ENV=production vite build --config ./vue/vite.config.ts",
"test:flame:react": "NODE_ENV=production flame run --md-format=detailed --delay=none --node-options=\"--stack-size=65500\" ./react/speed.flame.ts",
"test:flame:solid": "NODE_ENV=production flame run --md-format=detailed --delay=none --node-options=\"--stack-size=65500\" ./solid/speed.flame.ts",
"test:flame:vue": "NODE_ENV=production flame run --md-format=detailed --delay=none --node-options=\"--stack-size=65500\" ./vue/speed.flame.ts",
Expand All @@ -30,7 +30,7 @@
},
"devDependencies": {
"@platformatic/flame": "^1.6.0",
"@codspeed/vitest-plugin": "^5.0.1",
"@codspeed/vitest-plugin": "^5.5.0",
"@testing-library/react": "^16.2.0",
"@vitejs/plugin-react": "^6.0.1",
"@vitejs/plugin-vue": "^6.0.5",
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/client-nav/react/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import type * as App from './app'
import { getRequiredLink, waitForRequiredLink } from '../setup-helpers'

const appModulePath = './dist/app.js'
const { mountTestApp } = (await import(appModulePath)) as typeof App
const { mountTestApp } = (await import(
/* @vite-ignore */ appModulePath
)) as typeof App

export function setup() {
if (process.env.NODE_ENV !== 'production') {
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/client-nav/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import react from '@vitejs/plugin-react'
import codspeedPlugin from '@codspeed/vitest-plugin'

export default defineConfig({
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
plugins: [
!!(process.env.VITEST && process.env.WITH_INSTRUMENTATION) &&
codspeedPlugin(),
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/client-nav/solid/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import type * as App from './app'
import { getRequiredLink, waitForRequiredLink } from '../setup-helpers'

const appModulePath = './dist/app.js'
const { mountTestApp } = (await import(appModulePath)) as typeof App
const { mountTestApp } = (await import(
/* @vite-ignore */ appModulePath
)) as typeof App

export function setup() {
if (process.env.NODE_ENV !== 'production') {
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/client-nav/solid/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import solid from 'vite-plugin-solid'
import codspeedPlugin from '@codspeed/vitest-plugin'

export default defineConfig({
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
plugins: [
!!(process.env.VITEST && process.env.WITH_INSTRUMENTATION) &&
codspeedPlugin(),
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/client-nav/vue/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import type * as App from './app'
import { getRequiredLink, waitForRequiredLink } from '../setup-helpers'

const appModulePath = './dist/app.js'
const { mountTestApp } = (await import(appModulePath)) as typeof App
const { mountTestApp } = (await import(
/* @vite-ignore */ appModulePath
)) as typeof App

export function setup() {
if (process.env.NODE_ENV !== 'production') {
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"private": true,
"type": "module",
"scripts": {
"build:react": "vite build --config ./react/vite.config.ts",
"build:solid": "vite build --config ./solid/vite.config.ts",
"build:vue": "vite build --config ./vue/vite.config.ts",
"test:perf": "vitest bench",
"test:perf:react": "vitest bench --config ./react/vite.config.ts ./react/speed.bench.ts",
"test:perf:solid": "vitest bench --config ./solid/vite.config.ts ./solid/speed.bench.ts",
"test:perf:vue": "vitest bench --config ./vue/vite.config.ts ./vue/speed.bench.ts",
"build:react": "NODE_ENV=production vite build --config ./react/vite.config.ts",
"build:solid": "NODE_ENV=production vite build --config ./solid/vite.config.ts",
"build:vue": "NODE_ENV=production vite build --config ./vue/vite.config.ts",
"test:perf": "NODE_ENV=production vitest bench",
"test:perf:react": "NODE_ENV=production vitest bench --config ./react/vite.config.ts ./react/speed.bench.ts",
"test:perf:solid": "NODE_ENV=production vitest bench --config ./solid/vite.config.ts ./solid/speed.bench.ts",
"test:perf:vue": "NODE_ENV=production vitest bench --config ./vue/vite.config.ts ./vue/speed.bench.ts",
"test:types": "pnpm run test:types:react && pnpm run test:types:solid && pnpm run test:types:vue",
"test:types:react": "tsc -p ./react/tsconfig.json --noEmit",
"test:types:solid": "tsc -p ./solid/tsconfig.json --noEmit",
Expand All @@ -28,7 +28,7 @@
"vue": "^3.5.16"
},
"devDependencies": {
"@codspeed/vitest-plugin": "^5.0.1",
"@codspeed/vitest-plugin": "^5.5.0",
"@vitejs/plugin-react": "^6.0.1",
"@vitejs/plugin-vue-jsx": "^5.1.5",
"typescript": "^6.0.2",
Expand Down
38 changes: 6 additions & 32 deletions benchmarks/ssr/react/speed.bench.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
import { afterAll, beforeAll, bench, describe } from 'vitest'
import { bench, describe } from 'vitest'
import { runSsrRequestLoop } from '../bench-utils'
import type { StartRequestHandler } from '../bench-utils'

const appModulePath = './dist/server/server.js'
const appModuleUrl = new URL('./dist/server/server.js', import.meta.url).href
const benchmarkSeed = 0xdecafbad

const uninitializedHandler: StartRequestHandler = {
fetch: () => Promise.reject(new Error('Benchmark not initialized')),
}

let handler = uninitializedHandler

async function setup() {
const module = (await import(appModulePath)) as {
default: StartRequestHandler
}

handler = module.default
}

function teardown() {
handler = uninitializedHandler
const { default: handler } = (await import(
/* @vite-ignore */ appModuleUrl
)) as {
default: StartRequestHandler
}

describe('ssr', () => {
/**
* Running `vitest bench` ignores "suite hooks" like `beforeAll` and `afterAll`,
* so we use tinybench's `setup` and `teardown` options to run our setup and teardown logic.
*
* But CodSpeed calls the benchmarked function directly, bypassing `setup` and `teardown`,
* but it does support `beforeAll` and `afterAll`.
*
* So it looks like we're setting up in duplicate, but in reality, it's only running once per environment, as intended.
*/
beforeAll(setup)
afterAll(teardown)

bench(
'ssr request loop (react)',
() => runSsrRequestLoop(handler, { seed: benchmarkSeed }),
{
warmupIterations: 100,
time: 10_000,
setup,
teardown,
throws: true,
},
)
Expand Down
38 changes: 6 additions & 32 deletions benchmarks/ssr/solid/speed.bench.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
import { afterAll, beforeAll, bench, describe } from 'vitest'
import { bench, describe } from 'vitest'
import { runSsrRequestLoop } from '../bench-utils'
import type { StartRequestHandler } from '../bench-utils'

const appModulePath = './dist/server/server.js'
const appModuleUrl = new URL('./dist/server/server.js', import.meta.url).href
const benchmarkSeed = 0xcafebabe

const uninitializedHandler: StartRequestHandler = {
fetch: () => Promise.reject(new Error('Benchmark not initialized')),
}

let handler = uninitializedHandler

async function setup() {
const module = (await import(appModulePath)) as {
default: StartRequestHandler
}

handler = module.default
}

function teardown() {
handler = uninitializedHandler
const { default: handler } = (await import(
/* @vite-ignore */ appModuleUrl
)) as {
default: StartRequestHandler
}

describe('ssr', () => {
/**
* Running `vitest bench` ignores "suite hooks" like `beforeAll` and `afterAll`,
* so we use tinybench's `setup` and `teardown` options to run our setup and teardown logic.
*
* But CodSpeed calls the benchmarked function directly, bypassing `setup` and `teardown`,
* but it does support `beforeAll` and `afterAll`.
*
* So it looks like we're setting up in duplicate, but in reality, it's only running once per environment, as intended.
*/
beforeAll(setup)
afterAll(teardown)

bench(
'ssr request loop (solid)',
() => runSsrRequestLoop(handler, { seed: benchmarkSeed }),
{
warmupIterations: 100,
time: 10_000,
setup,
teardown,
throws: true,
},
)
Expand Down
38 changes: 6 additions & 32 deletions benchmarks/ssr/vue/speed.bench.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
import { afterAll, beforeAll, bench, describe } from 'vitest'
import { bench, describe } from 'vitest'
import { runSsrRequestLoop } from '../bench-utils'
import type { StartRequestHandler } from '../bench-utils'

const appModulePath = './dist/server/server.js'
const appModuleUrl = new URL('./dist/server/server.js', import.meta.url).href
const benchmarkSeed = 0xdeadbeef

const uninitializedHandler: StartRequestHandler = {
fetch: () => Promise.reject(new Error('Benchmark not initialized')),
}

let handler = uninitializedHandler

async function setup() {
const module = (await import(appModulePath)) as {
default: StartRequestHandler
}

handler = module.default
}

function teardown() {
handler = uninitializedHandler
const { default: handler } = (await import(
/* @vite-ignore */ appModuleUrl
)) as {
default: StartRequestHandler
}

describe('ssr', () => {
/**
* Running `vitest bench` ignores "suite hooks" like `beforeAll` and `afterAll`,
* so we use tinybench's `setup` and `teardown` options to run our setup and teardown logic.
*
* But CodSpeed calls the benchmarked function directly, bypassing `setup` and `teardown`,
* but it does support `beforeAll` and `afterAll`.
*
* So it looks like we're setting up in duplicate, but in reality, it's only running once per environment, as intended.
*/
beforeAll(setup)
afterAll(teardown)

bench(
'ssr request loop (vue)',
() => runSsrRequestLoop(handler, { seed: benchmarkSeed }),
{
warmupIterations: 100,
time: 10_000,
setup,
teardown,
throws: true,
},
)
Expand Down
42 changes: 19 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading