diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-06-25 23:50:16 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 15:50:16 +0200 |
commit | 6f09b8de4158417c3ffebcca316b806986c7b613 (patch) | |
tree | a27754be9cae53822366c7ec5227fc8edab76a01 | |
parent | 188839c87501f6b67d0e5d179121c16c5c1f21c0 (diff) |
Restore stats for incremental compile (#6474)
-rw-r--r-- | cli/js/compiler.ts | 14 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts index af95390e7..905f5efb2 100644 --- a/cli/js/compiler.ts +++ b/cli/js/compiler.ts @@ -943,7 +943,10 @@ function performanceStart(): void { 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: "Nodes", value: program.getNodeCount() }); stats.push({ key: "Identifiers", value: program.getIdentifierCount() }); @@ -1259,7 +1262,7 @@ type CompilerRequest = interface CompileResponse { emitMap: Record<string, EmittedSource>; diagnostics: Diagnostic; - buildInfo: undefined | string; + buildInfo?: string; stats?: Stats; } @@ -1290,7 +1293,11 @@ function compile({ cwd, sourceFileMap, type, + performance, }: CompileRequest): CompileResponse { + if (performance) { + performanceStart(); + } log(">>> compile start", { rootNames, type: CompilerRequestType[type] }); // When a programme is emitted, TypeScript will call `writeFile` with @@ -1359,14 +1366,17 @@ function compile({ // without casting. diagnostics = emitResult.diagnostics; } + performanceProgram(program); } log("<<< compile end", { rootNames, type: CompilerRequestType[type] }); + const stats = performance ? performanceEnd() : undefined; return { emitMap: state.emitMap, buildInfo: state.buildInfo, diagnostics: fromTypeScriptDiagnostic(diagnostics), + stats, }; } diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 890249072..b4bc47e08 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2049,7 +2049,7 @@ itest!(single_compile_with_reload { }); itest!(performance_stats { - args: "bundle --log-level debug 002_hello.ts", + args: "cache --reload --log-level debug 002_hello.ts", output: "performance_stats.out", }); |