Skip to content

Commit 4420d10

Browse files
authored
Add diagnostics for relation cache size (microsoft#30999)
* Add diagnostics for relation cache size * Move to extendedDiagnostics * Single method that returns a 3-property object * Fix double-space lint
1 parent 169e485 commit 4420d10

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ namespace ts {
114114
getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"),
115115
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount,
116116
getTypeCount: () => typeCount,
117+
getRelationCacheSizes: () => ({
118+
assignable: assignableRelation.size,
119+
identity: identityRelation.size,
120+
subtype: subtypeRelation.size,
121+
}),
117122
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
118123
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
119124
isUnknownSymbol: symbol => symbol === unknownSymbol,

src/compiler/program.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ namespace ts {
927927
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
928928
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
929929
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
930+
getRelationCacheSizes: () => getDiagnosticsProducingTypeChecker().getRelationCacheSizes(),
930931
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
931932
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
932933
isSourceFileFromExternalLibrary,

src/compiler/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,6 +2961,7 @@ namespace ts {
29612961
/* @internal */ getIdentifierCount(): number;
29622962
/* @internal */ getSymbolCount(): number;
29632963
/* @internal */ getTypeCount(): number;
2964+
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number };
29642965

29652966
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
29662967
/* @internal */ getResolvedTypeReferenceDirectives(): Map<ResolvedTypeReferenceDirective | undefined>;
@@ -3246,6 +3247,7 @@ namespace ts {
32463247
/* @internal */ getIdentifierCount(): number;
32473248
/* @internal */ getSymbolCount(): number;
32483249
/* @internal */ getTypeCount(): number;
3250+
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number };
32493251

32503252
/* @internal */ isArrayType(type: Type): boolean;
32513253
/* @internal */ isTupleType(type: Type): boolean;

src/tsc/tsc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ namespace ts {
340340
const checkTime = performance.getDuration("Check");
341341
const emitTime = performance.getDuration("Emit");
342342
if (compilerOptions.extendedDiagnostics) {
343+
const caches = program.getRelationCacheSizes();
344+
reportCountStatistic("Assignability cache size", caches.assignable);
345+
reportCountStatistic("Identity cache size", caches.identity);
346+
reportCountStatistic("Subtype cache size", caches.subtype);
343347
performance.forEachMeasure((name, duration) => reportTimeStatistic(`${name} time`, duration));
344348
}
345349
else {

0 commit comments

Comments
 (0)