docs/plans/benchmark-improvements/007-cleanup-legacy-benchmark-code.md
Remove deprecated patterns, unused code, and clean up the benchmark infrastructure after completing the migration to tinybench and refinements to the benchmark suite.
Benchmark Files
packages/client/src/__tests__/benchmarks/query-performance/query-performance.bench.tspackages/client/src/__tests__/benchmarks/query-performance/compilation.bench.tspackages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.tspackages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.tspackages/client-engine-runtime/bench/interpreter.bench.tspackages/get-platform/bench/get-platform.bench.tsHelper Files
packages/client/src/__tests__/benchmarks/query-performance/seed-data.tspackages/client/src/__tests__/benchmarks/huge-schema/builder.tspackages/client/src/__tests__/benchmarks/lots-of-relations/builder.tsPackage Configuration
@types/benchmark if still presentbenchmark package if not needed| Pattern | Action |
|---|---|
@ts-nocheck comments | Remove and fix type errors properly |
// eslint-disable comments | Remove and fix linting issues |
| Deferred callback pattern | Replace with async/await |
| Manual error handling in benchmarks | Use framework's error handling |
| Unused imports | Remove dead imports |
Check for and remove:
deferredBench, syncBench)Apply consistent patterns across all benchmark files:
File structure:
// 1. Imports
import { withCodSpeed } from '@codspeed/tinybench-plugin'
import { Bench } from 'tinybench'
// 2. Constants/Configuration
const BENCHMARK_CONFIG = { ... }
// 3. Helper functions
function setupBenchmark() { ... }
// 4. Benchmark definitions
async function runBenchmarks() {
const bench = withCodSpeed(new Bench({ name: '...' }))
// ...
}
// 5. Entry point
runBenchmarks().catch(console.error)
Naming conventions:
category: specific operationcamelCaseUPPER_SNAKE_CASECheck for duplicated types across files:
Consider extracting shared types to:
packages/client/src/__tests__/benchmarks/shared/types.tsAfter tinybench migration, verify these are removed:
// Should NOT be present after migration
"@codspeed/benchmark.js-plugin": "...",
"@types/benchmark": "...",
"benchmark": "..."
Current issues:
@ts-nocheck at top of fileprocess.exit(1)Actions:
@ts-nocheck, fix type errorsCurrent issues:
@ts-nocheck at top of file@ts-ignore and eslint-disable commentsActions:
Current issues:
Actions:
deferredBench/syncBench helpersCurrent issues:
Actions:
Current issues:
Actions:
After cleanup:
# Verify no type errors
pnpm tsc --noEmit
# Verify linting passes
pnpm lint
# Verify all benchmarks still work
pnpm bench
# Verify formatting
pnpm format --check
@ts-nocheck comments removed@ts-ignore comments removed or justifiedeslint-disable comments removed or justifiedpnpm lint passespnpm build succeedspnpm bench runs successfullyAfter cleanup, all benchmark files should: