Skip to content

Commit

Permalink
chore: add scripts to monitor type check performance
Browse files Browse the repository at this point in the history
  • Loading branch information
m-shaka committed Sep 11, 2024
1 parent f9a23a9 commit eda7540
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions type-check-perf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
app.ts
trace
4 changes: 4 additions & 0 deletions type-check-perf/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { app } from './app'
import { hc } from '../src/client'

const client = hc<typeof app>('/')
24 changes: 24 additions & 0 deletions type-check-perf/generate-app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { writeFile } from 'node:fs'

const count = 200

const generateRoutes = (count: number) => {
let routes = `import { Hono } from '../src'
export const app = new Hono()`
for (let i = 1; i <= count; i++) {
routes += `
.get('/route${i}/:id', (c) => {
return c.json({
ok: true
})
})`
}
return routes
}

const routes = generateRoutes(count)

writeFile(import.meta.dirname + '/app.ts', routes, (err) => {
if (err) throw err
console.log(`${count} routes have been written to app.ts`)
})
12 changes: 12 additions & 0 deletions type-check-perf/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"noEmit": true,
"rootDir": ".."
},
"include": [
"**/*.ts",
"**/*.tsx"
]
}

0 comments on commit eda7540

Please sign in to comment.