Skip to content

chore(bench): add vitest benchmarks for runtime and type-checking performance#3

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-benchmark-for-runtime-and-type
Draft

chore(bench): add vitest benchmarks for runtime and type-checking performance#3
Copilot wants to merge 2 commits into
mainfrom
copilot/add-benchmark-for-runtime-and-type

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

Establishes baseline benchmarks for runtime builder performance and TypeScript type-inference cost, enabling data-driven type optimization.

bench/runtime.bench.ts

Measures JS execution speed across the full builder API surface:

  • Operation builder – 8 cases from flat string fields to 4-level deep nesting, variables+args, inline fragments, directives, mutations
  • Fragment builder – simple, with variables, with directives
  • Partial builder – create package, spread into query
  • Gazania facade – public gazania singleton for each builder type

bench/type.bench.ts

Measures getSemanticDiagnostics() time via the TypeScript compiler API across 8 scenarios of increasing selection complexity:

simple scalar → flat multi-field → nested 1-level → nested 2-levels
  → union inline fragments → partial spread → fragment → complex mixed

Each iteration creates a fresh ts.createProgram + compiler host to avoid cache pollution. Uses { iterations: 3, warmupIterations: 1 } since each TypeScript compilation costs ~500ms. Each case asserts zero type errors so broken fixtures surface immediately.

Compiler setup: types: ['vitest/importMeta'] + typeRoots pointing to project node_modules silences the import.meta.vitest guards present in source files. The virtual file lives at bench/_virtual_type_bench_.ts so relative imports (../src/index, ../test/types/schema) resolve against the real project layout without absolute paths.

vitest.config.ts

Added benchmark: { include: ['bench/**/*.bench.ts'] }.

Run with:

vitest bench --run

@Teages Teages changed the title feat: add vitest benchmarks for runtime and type-checking performance chore(bench): add vitest benchmarks for runtime and type-checking performance Apr 21, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 21, 2026

Deploying gazania with  Cloudflare Pages  Cloudflare Pages

Latest commit: e092444
Status: ✅  Deploy successful!
Preview URL: https://c1539c12.gazania.pages.dev
Branch Preview URL: https://copilot-add-benchmark-for-ru.gazania.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants