From eda7540b0112b50ec617e08ee74636823106a9e5 Mon Sep 17 00:00:00 2001 From: m-shaka Date: Wed, 11 Sep 2024 23:00:55 +0900 Subject: [PATCH] chore: add scripts to monitor type check performance --- type-check-perf/.gitignore | 2 ++ type-check-perf/client.ts | 4 ++++ type-check-perf/generate-app.ts | 24 ++++++++++++++++++++++++ type-check-perf/tsconfig.json | 12 ++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 type-check-perf/.gitignore create mode 100644 type-check-perf/client.ts create mode 100644 type-check-perf/generate-app.ts create mode 100644 type-check-perf/tsconfig.json diff --git a/type-check-perf/.gitignore b/type-check-perf/.gitignore new file mode 100644 index 000000000..8f1b52cd9 --- /dev/null +++ b/type-check-perf/.gitignore @@ -0,0 +1,2 @@ +app.ts +trace diff --git a/type-check-perf/client.ts b/type-check-perf/client.ts new file mode 100644 index 000000000..19d9ffe2d --- /dev/null +++ b/type-check-perf/client.ts @@ -0,0 +1,4 @@ +import { app } from './app' +import { hc } from '../src/client' + +const client = hc('/') diff --git a/type-check-perf/generate-app.ts b/type-check-perf/generate-app.ts new file mode 100644 index 000000000..2a2629f65 --- /dev/null +++ b/type-check-perf/generate-app.ts @@ -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`) +}) diff --git a/type-check-perf/tsconfig.json b/type-check-perf/tsconfig.json new file mode 100644 index 000000000..338aea486 --- /dev/null +++ b/type-check-perf/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "module": "esnext", + "noEmit": true, + "rootDir": ".." + }, + "include": [ + "**/*.ts", + "**/*.tsx" + ] +}