From 4420d1083b052da55ac294bae9948370bc257119 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 17 Apr 2019 14:32:18 -0700 Subject: [PATCH] Add diagnostics for relation cache size (#30999) * Add diagnostics for relation cache size * Move to extendedDiagnostics * Single method that returns a 3-property object * Fix double-space lint --- src/compiler/checker.ts | 5 +++++ src/compiler/program.ts | 1 + src/compiler/types.ts | 2 ++ src/tsc/tsc.ts | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0c91e1ba06..48a9c2e745 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -114,6 +114,11 @@ namespace ts { getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"), getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount, getTypeCount: () => typeCount, + getRelationCacheSizes: () => ({ + assignable: assignableRelation.size, + identity: identityRelation.size, + subtype: subtypeRelation.size, + }), isUndefinedSymbol: symbol => symbol === undefinedSymbol, isArgumentsSymbol: symbol => symbol === argumentsSymbol, isUnknownSymbol: symbol => symbol === unknownSymbol, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 74bb8e1b1c..4f50aa3ab1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -927,6 +927,7 @@ namespace ts { getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(), getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(), getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(), + getRelationCacheSizes: () => getDiagnosticsProducingTypeChecker().getRelationCacheSizes(), getFileProcessingDiagnostics: () => fileProcessingDiagnostics, getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives, isSourceFileFromExternalLibrary, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6fba5f149c..1e50c59fc9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2961,6 +2961,7 @@ namespace ts { /* @internal */ getIdentifierCount(): number; /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number }; /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; /* @internal */ getResolvedTypeReferenceDirectives(): Map; @@ -3246,6 +3247,7 @@ namespace ts { /* @internal */ getIdentifierCount(): number; /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number }; /* @internal */ isArrayType(type: Type): boolean; /* @internal */ isTupleType(type: Type): boolean; diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 984ebe21cf..500480463b 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -340,6 +340,10 @@ namespace ts { const checkTime = performance.getDuration("Check"); const emitTime = performance.getDuration("Emit"); if (compilerOptions.extendedDiagnostics) { + const caches = program.getRelationCacheSizes(); + reportCountStatistic("Assignability cache size", caches.assignable); + reportCountStatistic("Identity cache size", caches.identity); + reportCountStatistic("Subtype cache size", caches.subtype); performance.forEachMeasure((name, duration) => reportTimeStatistic(`${name} time`, duration)); } else {