-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbenchmark.bench.ts
More file actions
36 lines (32 loc) · 1.26 KB
/
benchmark.bench.ts
File metadata and controls
36 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {execSync} from 'node:child_process';
import * as path from 'node:path';
import {bench, describe} from 'vitest';
const cliPath = path.resolve(__dirname, '../dist/cli/index.js');
const fixtureDir = path.resolve(__dirname, 'benchmarks/synthetic-monorepo');
const cmd = `node ${cliPath} generate --config schema/drizzle-zero.config.ts --output /tmp/drizzle-zero-bench-output.ts --suppress-defaults-warning --force`;
// This synthetic benchmark shows a modest ~1.2x speedup because the fixture files
// are small and self-contained. In real monorepos with heavy type dependencies
// (Effect-TS, Drizzle ORM, etc.), the improvement is 4x+ because the eager path
// loads all files AND their transitive type dependencies from node_modules.
//
// Set DRIZZLE_ZERO_EAGER_LOADING=1 to force the old eager loading behavior.
describe('generate', () => {
bench(
'eager (DRIZZLE_ZERO_EAGER_LOADING=1)',
() => {
execSync(cmd, {
cwd: fixtureDir,
stdio: 'ignore',
env: {...process.env, DRIZZLE_ZERO_EAGER_LOADING: '1'},
});
},
{warmupIterations: 1, iterations: 5, time: 0},
);
bench(
'lazy (default)',
() => {
execSync(cmd, {cwd: fixtureDir, stdio: 'ignore'});
},
{warmupIterations: 1, iterations: 5, time: 0},
);
});