mirror of
https://github.com/denoland/deno.git
synced 2025-01-05 05:49:20 -05:00
Restore stats for incremental compile (#6474)
This commit is contained in:
parent
188839c875
commit
6f09b8de41
2 changed files with 13 additions and 3 deletions
|
@ -943,7 +943,10 @@ function performanceStart(): void {
|
||||||
ts.performance.enable();
|
ts.performance.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
function performanceProgram(program: ts.Program): void {
|
function performanceProgram(program: ts.Program | ts.BuilderProgram): void {
|
||||||
|
if ("getProgram" in program) {
|
||||||
|
program = program.getProgram();
|
||||||
|
}
|
||||||
stats.push({ key: "Files", value: program.getSourceFiles().length });
|
stats.push({ key: "Files", value: program.getSourceFiles().length });
|
||||||
stats.push({ key: "Nodes", value: program.getNodeCount() });
|
stats.push({ key: "Nodes", value: program.getNodeCount() });
|
||||||
stats.push({ key: "Identifiers", value: program.getIdentifierCount() });
|
stats.push({ key: "Identifiers", value: program.getIdentifierCount() });
|
||||||
|
@ -1259,7 +1262,7 @@ type CompilerRequest =
|
||||||
interface CompileResponse {
|
interface CompileResponse {
|
||||||
emitMap: Record<string, EmittedSource>;
|
emitMap: Record<string, EmittedSource>;
|
||||||
diagnostics: Diagnostic;
|
diagnostics: Diagnostic;
|
||||||
buildInfo: undefined | string;
|
buildInfo?: string;
|
||||||
stats?: Stats;
|
stats?: Stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,7 +1293,11 @@ function compile({
|
||||||
cwd,
|
cwd,
|
||||||
sourceFileMap,
|
sourceFileMap,
|
||||||
type,
|
type,
|
||||||
|
performance,
|
||||||
}: CompileRequest): CompileResponse {
|
}: CompileRequest): CompileResponse {
|
||||||
|
if (performance) {
|
||||||
|
performanceStart();
|
||||||
|
}
|
||||||
log(">>> compile start", { rootNames, type: CompilerRequestType[type] });
|
log(">>> compile start", { rootNames, type: CompilerRequestType[type] });
|
||||||
|
|
||||||
// When a programme is emitted, TypeScript will call `writeFile` with
|
// When a programme is emitted, TypeScript will call `writeFile` with
|
||||||
|
@ -1359,14 +1366,17 @@ function compile({
|
||||||
// without casting.
|
// without casting.
|
||||||
diagnostics = emitResult.diagnostics;
|
diagnostics = emitResult.diagnostics;
|
||||||
}
|
}
|
||||||
|
performanceProgram(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
log("<<< compile end", { rootNames, type: CompilerRequestType[type] });
|
log("<<< compile end", { rootNames, type: CompilerRequestType[type] });
|
||||||
|
const stats = performance ? performanceEnd() : undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
emitMap: state.emitMap,
|
emitMap: state.emitMap,
|
||||||
buildInfo: state.buildInfo,
|
buildInfo: state.buildInfo,
|
||||||
diagnostics: fromTypeScriptDiagnostic(diagnostics),
|
diagnostics: fromTypeScriptDiagnostic(diagnostics),
|
||||||
|
stats,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2049,7 +2049,7 @@ itest!(single_compile_with_reload {
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(performance_stats {
|
itest!(performance_stats {
|
||||||
args: "bundle --log-level debug 002_hello.ts",
|
args: "cache --reload --log-level debug 002_hello.ts",
|
||||||
output: "performance_stats.out",
|
output: "performance_stats.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue