|
| 1 | +import {execSync} from 'node:child_process'; |
1 | 2 | import * as path from 'node:path'; |
2 | | -import {Project} from 'ts-morph'; |
3 | 3 | import {bench, describe} from 'vitest'; |
4 | | -import { |
5 | | - addSourceFilesFromTsConfigSafe, |
6 | | - ensureSourceFileInProject, |
7 | | -} from '../src/cli/ts-project'; |
8 | | -import {discoverAllTsConfigs} from '../src/cli/tsconfig'; |
9 | 4 |
|
10 | | -const fixtureRoot = path.resolve( |
11 | | - __dirname, |
12 | | - 'benchmarks/synthetic-monorepo/tsconfig.json', |
13 | | -); |
14 | | -const schemaConfigFile = path.resolve( |
15 | | - __dirname, |
16 | | - 'benchmarks/synthetic-monorepo/schema/drizzle-zero.config.ts', |
17 | | -); |
| 5 | +const cliPath = path.resolve(__dirname, '../dist/cli/index.js'); |
| 6 | +const fixtureDir = path.resolve(__dirname, 'benchmarks/synthetic-monorepo'); |
18 | 7 |
|
19 | | -describe('file loading', () => { |
20 | | - bench('eager: load all files from all tsconfigs', async () => { |
21 | | - const allTsConfigPaths = await discoverAllTsConfigs(fixtureRoot); |
22 | | - const project = new Project({ |
23 | | - tsConfigFilePath: fixtureRoot, |
24 | | - skipAddingFilesFromTsConfig: true, |
25 | | - }); |
26 | | - for (const tsConfigPath of allTsConfigPaths) { |
27 | | - addSourceFilesFromTsConfigSafe({tsProject: project, tsConfigPath}); |
28 | | - } |
29 | | - }); |
30 | | - |
31 | | - bench('targeted: load only the requested file', async () => { |
32 | | - const project = new Project({ |
33 | | - tsConfigFilePath: fixtureRoot, |
34 | | - skipAddingFilesFromTsConfig: true, |
35 | | - }); |
36 | | - ensureSourceFileInProject({ |
37 | | - tsProject: project, |
38 | | - filePath: schemaConfigFile, |
39 | | - debug: false, |
40 | | - }); |
41 | | - }); |
| 8 | +describe('generate', () => { |
| 9 | + bench( |
| 10 | + 'end-to-end generate on synthetic monorepo', |
| 11 | + () => { |
| 12 | + execSync( |
| 13 | + `node ${cliPath} generate --config schema/drizzle-zero.config.ts --output /tmp/drizzle-zero-bench-output.ts --suppress-defaults-warning --force`, |
| 14 | + {cwd: fixtureDir, stdio: 'ignore'}, |
| 15 | + ); |
| 16 | + }, |
| 17 | + {warmupIterations: 1, iterations: 5, time: 0}, |
| 18 | + ); |
42 | 19 | }); |
0 commit comments