Skip to content

Commit 6cdd106

Browse files
committed
feat(openapi-ts): log codegen time
1 parent 3612127 commit 6cdd106

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

packages/openapi-ts/src/createClient.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ export async function createClient({
166166
eventParser.timeEnd();
167167

168168
const eventGenerator = logger.timeEvent('generator');
169-
const genStart = Date.now();
170-
const { fileCount } = await generateOutput(context);
171-
const genMs = Date.now() - genStart;
169+
const { codegenMs, fileCount, writeMs } = await generateOutput(context);
172170
eventGenerator.timeEnd();
173171

174172
const eventPostprocess = logger.timeEvent('postprocess');
@@ -181,7 +179,7 @@ export async function createClient({
181179
? `./${path.relative(process.env.INIT_CWD, config.output.path)}`
182180
: config.output.path;
183181
console.log(
184-
`${jobPrefix}${colors.green('✅ Done!')} Your output is in ${colors.cyanBright(outputPath)} ${colors.gray(`(${fileCount} files written in ${(genMs / 1000).toFixed(2)}s)`)}`,
182+
`${jobPrefix}${colors.green('✅ Done!')} Your output is in ${colors.cyanBright(outputPath)} ${colors.gray(`(${fileCount} files, codegen ${(codegenMs / 1000).toFixed(2)}s, write ${(writeMs / 1000).toFixed(2)}s)`)}`,
185183
);
186184
}
187185
}

packages/openapi-ts/src/generate/output.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { getTypedConfig } from '../config/utils';
99
import { getClientPlugin } from '../plugins/@hey-api/client-core/utils';
1010
import { generateClientBundle } from './client';
1111

12-
export async function generateOutput(context: Context): Promise<{ fileCount: number }> {
12+
export async function generateOutput(
13+
context: Context,
14+
): Promise<{ codegenMs: number; fileCount: number; writeMs: number }> {
1315
const outputPath = path.resolve(context.config.output.path);
1416

1517
if (context.config.output.clean) {
@@ -34,6 +36,7 @@ export async function generateOutput(context: Context): Promise<{ fileCount: num
3436
});
3537
}
3638

39+
const codegenStart = Date.now();
3740
for (const plugin of context.registerPlugins()) {
3841
await plugin.run();
3942
}
@@ -59,6 +62,9 @@ export async function generateOutput(context: Context): Promise<{ fileCount: num
5962
}
6063
fileCount++;
6164
}
65+
const codegenMs = Date.now() - codegenStart;
66+
67+
const writeStart = Date.now();
6268
await Promise.all(writes);
6369

6470
const { source } = context.config.output;
@@ -82,5 +88,6 @@ export async function generateOutput(context: Context): Promise<{ fileCount: num
8288
}
8389
}
8490

85-
return { fileCount };
91+
const writeMs = Date.now() - writeStart;
92+
return { codegenMs, fileCount, writeMs };
8693
}

0 commit comments

Comments
 (0)