Skip to content

Commit 6011176

Browse files
Automatic perf stats in baselines (#57730)
1 parent aeddd65 commit 6011176

File tree

149 files changed

+933
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+933
-1
lines changed

src/harness/harnessIO.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,57 @@ export namespace Compiler {
776776

777777
function generateBaseLine(isSymbolBaseline: boolean, skipBaseline?: boolean): string | null {
778778
let result = "";
779+
const perfLines: string[] = [];
780+
const prePerformanceValues = getPerformanceBaselineValues();
779781
const gen = iterateBaseLine(isSymbolBaseline, skipBaseline);
780782
for (const value of gen) {
781783
const [, content] = value;
782784
result += content;
783785
}
784-
return result ? (`//// [${header}] ////\r\n\r\n` + result) : null; // eslint-disable-line no-null/no-null
786+
const postPerformanceValues = getPerformanceBaselineValues();
787+
788+
if (!isSymbolBaseline) {
789+
const perfStats: [name: string, reportThreshold: number, rounding: number, beforeValue: number, afterValue: number][] = [];
790+
perfStats.push(["Strict subtype cache", 1000, 100, prePerformanceValues.strictSubtype, postPerformanceValues.strictSubtype]);
791+
perfStats.push(["Subtype cache", 1000, 100, prePerformanceValues.subtype, postPerformanceValues.subtype]);
792+
perfStats.push(["Identity cache", 1000, 100, prePerformanceValues.identity, postPerformanceValues.identity]);
793+
perfStats.push(["Assignability cache", 1000, 100, prePerformanceValues.assignability, postPerformanceValues.assignability]);
794+
perfStats.push(["Type Count", 1000, 100, prePerformanceValues.typeCount, postPerformanceValues.typeCount]);
795+
perfStats.push(["Instantiation count", 1500, 500, prePerformanceValues.instantiation, postPerformanceValues.instantiation]);
796+
perfStats.push(["Symbol count", 45000, 500, prePerformanceValues.symbol, postPerformanceValues.symbol]);
797+
798+
if (perfStats.some(([, threshold, , , postValue]) => postValue >= threshold)) {
799+
perfLines.push(`=== Performance Stats ===`);
800+
for (const [name, _, rounding, preValue, postValue] of perfStats) {
801+
const preDisplay = valueToString(preValue, rounding);
802+
if (preDisplay !== "0") {
803+
perfLines.push(`${name}: ${preDisplay} / ${valueToString(postValue, rounding)} (nearest ${rounding})`);
804+
}
805+
}
806+
perfLines.push("");
807+
perfLines.push("");
808+
}
809+
}
810+
811+
return result ? (`//// [${header}] ////\r\n\r\n${perfLines.join("\n")}${result}`) : null; // eslint-disable-line no-null/no-null
812+
}
813+
814+
function valueToString(value: number, rounding: number) {
815+
return (Math.round(value / rounding) * rounding).toLocaleString("en-US");
816+
}
817+
818+
function getPerformanceBaselineValues() {
819+
const checker = program.getTypeChecker();
820+
const caches = checker.getRelationCacheSizes();
821+
return {
822+
strictSubtype: caches.strictSubtype,
823+
subtype: caches.subtype,
824+
identity: caches.identity,
825+
assignability: caches.assignable,
826+
typeCount: checker.getTypeCount(),
827+
instantiation: checker.getInstantiationCount(),
828+
symbol: checker.getSymbolCount(),
829+
};
785830
}
786831

787832
function* iterateBaseLine(isSymbolBaseline: boolean, skipBaseline?: boolean): IterableIterator<[string, string]> {

tests/baselines/reference/APILibCheck.types

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//// [tests/cases/compiler/APILibCheck.ts] ////
22

3+
=== Performance Stats ===
4+
Identity cache: 100 / 100 (nearest 100)
5+
Assignability cache: 9,300 / 9,300 (nearest 100)
6+
Type Count: 22,500 / 22,500 (nearest 100)
7+
Instantiation count: 7,000 / 7,000 (nearest 500)
8+
Symbol count: 58,500 / 58,500 (nearest 500)
9+
310
=== index.ts ===
411
import ts = require("typescript");
512
>ts : typeof ts

tests/baselines/reference/awaitedType.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/awaitedType.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 200 / 200 (nearest 100)
5+
Type Count: 900 / 900 (nearest 100)
6+
Instantiation count: 26,000 / 26,000 (nearest 500)
7+
Symbol count: 31,500 / 31,500 (nearest 500)
8+
39
=== awaitedType.ts ===
410
type T1 = Awaited<number>;
511
>T1 : number

tests/baselines/reference/awaitedTypeStrictNull.types

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//// [tests/cases/compiler/awaitedTypeStrictNull.ts] ////
22

3+
=== Performance Stats ===
4+
Identity cache: 100 / 100 (nearest 100)
5+
Assignability cache: 200 / 200 (nearest 100)
6+
Type Count: 700 / 700 (nearest 100)
7+
Instantiation count: 25,500 / 25,500 (nearest 500)
8+
Symbol count: 30,500 / 30,500 (nearest 500)
9+
310
=== awaitedTypeStrictNull.ts ===
411
type T1 = Awaited<number>;
512
>T1 : number

tests/baselines/reference/callsOnComplexSignatures.types

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//// [tests/cases/compiler/callsOnComplexSignatures.tsx] ////
22

3+
=== Performance Stats ===
4+
Subtype cache: 100 / 100 (nearest 100)
5+
Assignability cache: 2,400 / 2,400 (nearest 100)
6+
Type Count: 8,200 / 8,200 (nearest 100)
7+
Instantiation count: 92,500 / 92,500 (nearest 500)
8+
Symbol count: 68,000 / 68,000 (nearest 500)
9+
310
=== callsOnComplexSignatures.tsx ===
411
/// <reference path="react16.d.ts" />
512
import React from "react";

tests/baselines/reference/checkJsxChildrenCanBeTupleType.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/jsx/checkJsxChildrenCanBeTupleType.tsx] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 2,200 / 2,200 (nearest 100)
5+
Type Count: 7,800 / 7,800 (nearest 100)
6+
Instantiation count: 90,000 / 90,000 (nearest 500)
7+
Symbol count: 66,500 / 66,500 (nearest 500)
8+
39
=== checkJsxChildrenCanBeTupleType.tsx ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/checkJsxChildrenProperty16.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/jsx/checkJsxChildrenProperty16.tsx] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 2,200 / 2,200 (nearest 100)
5+
Type Count: 7,600 / 7,600 (nearest 100)
6+
Instantiation count: 89,500 / 89,500 (nearest 500)
7+
Symbol count: 66,000 / 66,000 (nearest 500)
8+
39
=== checkJsxChildrenProperty16.tsx ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/checkJsxUnionSFXContextualTypeInferredCorrectly.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/jsx/checkJsxUnionSFXContextualTypeInferredCorrectly.tsx] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 2,200 / 2,200 (nearest 100)
5+
Type Count: 7,600 / 7,600 (nearest 100)
6+
Instantiation count: 89,500 / 89,500 (nearest 500)
7+
Symbol count: 66,500 / 66,500 (nearest 500)
8+
39
=== checkJsxUnionSFXContextualTypeInferredCorrectly.tsx ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/circularBaseConstraint.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/circularBaseConstraint.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 100 / 100 (nearest 100)
5+
Type Count: 600 / 600 (nearest 100)
6+
Instantiation count: 2,000 / 2,000 (nearest 500)
7+
Symbol count: 25,500 / 25,500 (nearest 500)
8+
39
=== circularBaseConstraint.ts ===
410
// Repro from #54610
511

tests/baselines/reference/circularlySimplifyingConditionalTypesNoCrash.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 300 / 300 (nearest 100)
5+
Type Count: 600 / 600 (nearest 100)
6+
Instantiation count: 2,000 / 2,000 (nearest 500)
7+
Symbol count: 25,500 / 25,500 (nearest 500)
8+
39
=== circularlySimplifyingConditionalTypesNoCrash.ts ===
410
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
511
>Omit : Omit<T, K>

tests/baselines/reference/complexRecursiveCollections.types

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//// [tests/cases/compiler/complexRecursiveCollections.ts] ////
22

3+
=== Performance Stats ===
4+
Identity cache: 600 / 600 (nearest 100)
5+
Assignability cache: 7,600 / 7,600 (nearest 100)
6+
Type Count: 53,300 / 53,300 (nearest 100)
7+
Instantiation count: 178,000 / 178,000 (nearest 500)
8+
Symbol count: 134,500 / 134,500 (nearest 500)
9+
310
=== complex.ts ===
411
interface Ara<T> { t: T }
512
>t : T

tests/baselines/reference/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.types

Lines changed: 7 additions & 0 deletions
Large diffs are not rendered by default.

tests/baselines/reference/conditionalTypeDoesntSpinForever.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/conditionalTypeDoesntSpinForever.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 600 / 600 (nearest 100)
5+
Type Count: 1,400 / 1,600 (nearest 100)
6+
Instantiation count: 3,500 / 4,000 (nearest 500)
7+
Symbol count: 28,000 / 28,000 (nearest 500)
8+
39
=== conditionalTypeDoesntSpinForever.ts ===
410
// A *self-contained* demonstration of the problem follows...
511
// Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

tests/baselines/reference/conditionalTypeVarianceBigArrayConstraintsPerformance.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/conditionalTypeVarianceBigArrayConstraintsPerformance.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 1,300 / 1,300 (nearest 100)
5+
Type Count: 5,900 / 5,900 (nearest 100)
6+
Instantiation count: 76,500 / 76,500 (nearest 500)
7+
Symbol count: 67,500 / 67,500 (nearest 500)
8+
39
=== conditionalTypeVarianceBigArrayConstraintsPerformance.ts ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/conditionalTypes1.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/types/conditional/conditionalTypes1.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 300 / 300 (nearest 100)
5+
Type Count: 900 / 900 (nearest 100)
6+
Instantiation count: 1,500 / 1,500 (nearest 500)
7+
Symbol count: 26,000 / 26,500 (nearest 500)
8+
39
=== conditionalTypes1.ts ===
410
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
511
>T00 : "b" | "d"

tests/baselines/reference/contextuallyTypedJsxChildren.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/contextuallyTypedJsxChildren.tsx] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 2,200 / 2,200 (nearest 100)
5+
Type Count: 7,800 / 7,800 (nearest 100)
6+
Instantiation count: 90,000 / 90,000 (nearest 500)
7+
Symbol count: 67,000 / 67,000 (nearest 500)
8+
39
=== contextuallyTypedJsxChildren.tsx ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/controlFlowOptionalChain3.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/controlFlow/controlFlowOptionalChain3.tsx] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 2,100 / 2,100 (nearest 100)
5+
Type Count: 7,600 / 7,600 (nearest 100)
6+
Instantiation count: 89,500 / 89,500 (nearest 500)
7+
Symbol count: 66,500 / 66,500 (nearest 500)
8+
39
=== controlFlowOptionalChain3.tsx ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/correlatedUnions.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/correlatedUnions.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 500 / 500 (nearest 100)
5+
Type Count: 1,000 / 1,000 (nearest 100)
6+
Instantiation count: 1,000 / 1,000 (nearest 500)
7+
Symbol count: 26,500 / 26,500 (nearest 500)
8+
39
=== correlatedUnions.ts ===
410
// Various repros from #30581
511

tests/baselines/reference/declarationEmitRecursiveConditionalAliasPreserved.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/declarationEmitRecursiveConditionalAliasPreserved.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 1,900 / 1,900 (nearest 100)
5+
Type Count: 14,200 / 14,200 (nearest 100)
6+
Instantiation count: 57,000 / 57,000 (nearest 500)
7+
Symbol count: 49,000 / 49,000 (nearest 500)
8+
39
=== input.d.ts ===
410
type _BuildPowersOf2LengthArrays<
511
>_BuildPowersOf2LengthArrays : _BuildPowersOf2LengthArrays<Length, AccumulatedArray>

tests/baselines/reference/declarationsAndAssignments.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 100 / 100 (nearest 100)
5+
Type Count: 500 / 1,200 (nearest 100)
6+
Instantiation count: 500 / 500 (nearest 500)
7+
Symbol count: 27,000 / 28,000 (nearest 500)
8+
39
=== declarationsAndAssignments.ts ===
410
function f0() {
511
>f0 : () => void

tests/baselines/reference/deepComparisons.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/deepComparisons.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 300 / 300 (nearest 100)
5+
Type Count: 2,000 / 2,100 (nearest 100)
6+
Instantiation count: 3,500 / 3,500 (nearest 500)
7+
Symbol count: 26,500 / 27,000 (nearest 500)
8+
39
=== deepComparisons.ts ===
410
function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>() {
511
>f1 : <T, K1 extends keyof T, K2 extends keyof T[K1]>() => void

tests/baselines/reference/deeplyNestedMappedTypes.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/deeplyNestedMappedTypes.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 500 / 600 (nearest 100)
5+
Type Count: 1,500 / 1,500 (nearest 100)
6+
Instantiation count: 15,500 / 15,500 (nearest 500)
7+
Symbol count: 26,000 / 26,000 (nearest 500)
8+
39
=== deeplyNestedMappedTypes.ts ===
410
// Simplified repro from #55535
511

tests/baselines/reference/dependentDestructuredVariables.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 300 / 300 (nearest 100)
5+
Type Count: 2,200 / 2,300 (nearest 100)
6+
Instantiation count: 1,500 / 1,500 (nearest 500)
7+
Symbol count: 34,000 / 34,000 (nearest 500)
8+
39
=== dependentDestructuredVariables.ts ===
410
type Action =
511
>Action : { kind: 'A'; payload: number; } | { kind: 'B'; payload: string; }

tests/baselines/reference/duplicateNumericIndexers.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/conformance/types/members/duplicateNumericIndexers.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 3,600 / 3,600 (nearest 100)
5+
Type Count: 12,600 / 12,600 (nearest 100)
6+
Instantiation count: 2,500 / 2,500 (nearest 500)
7+
Symbol count: 29,000 / 29,000 (nearest 500)
8+
39
=== duplicateNumericIndexers.ts ===
410
// it is an error to have duplicate index signatures of the same kind in a type
511

tests/baselines/reference/enumLiteralsSubtypeReduction.types

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//// [tests/cases/compiler/enumLiteralsSubtypeReduction.ts] ////
22

3+
=== Performance Stats ===
4+
Type Count: 3,200 / 3,200 (nearest 100)
5+
Symbol count: 26,500 / 26,500 (nearest 500)
6+
37
=== enumLiteralsSubtypeReduction.ts ===
48
enum E {
59
>E : E

tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 2,300 / 2,300 (nearest 100)
5+
Type Count: 10,100 / 10,100 (nearest 100)
6+
Instantiation count: 229,000 / 229,000 (nearest 500)
7+
Symbol count: 105,500 / 105,500 (nearest 500)
8+
39
=== errorInfoForRelatedIndexTypesNoConstraintElaboration.ts ===
410
/// <reference path="react16.d.ts" />
511

tests/baselines/reference/excessiveStackDepthFlatArray.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/excessiveStackDepthFlatArray.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 200 / 200 (nearest 100)
5+
Type Count: 900 / 900 (nearest 100)
6+
Instantiation count: 1,500 / 1,500 (nearest 500)
7+
Symbol count: 28,000 / 28,000 (nearest 500)
8+
39
=== index.tsx ===
410
interface MiddlewareArray<T> extends Array<T> {}
511
declare function configureStore(options: { middleware: MiddlewareArray<any> }): void;

tests/baselines/reference/excessivelyLargeTupleSpread.types

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//// [tests/cases/compiler/excessivelyLargeTupleSpread.ts] ////
22

3+
=== Performance Stats ===
4+
Type Count: 33,100 / 33,100 (nearest 100)
5+
Instantiation count: 49,500 / 49,500 (nearest 500)
6+
Symbol count: 108,000 / 108,000 (nearest 500)
7+
38
=== excessivelyLargeTupleSpread.ts ===
49
// #41771
510

tests/baselines/reference/fixSignatureCaching.types

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//// [tests/cases/conformance/fixSignatureCaching.ts] ////
22

3+
=== Performance Stats ===
4+
Type Count: 1,300 / 1,300 (nearest 100)
5+
Symbol count: 26,500 / 27,000 (nearest 500)
6+
37
=== fixSignatureCaching.ts ===
48
// Repro from #10697
59

tests/baselines/reference/flatArrayNoExcessiveStackDepth.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//// [tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts] ////
22

3+
=== Performance Stats ===
4+
Assignability cache: 200 / 200 (nearest 100)
5+
Type Count: 1,100 / 1,100 (nearest 100)
6+
Instantiation count: 2,500 / 2,500 (nearest 500)
7+
Symbol count: 31,000 / 31,000 (nearest 500)
8+
39
=== flatArrayNoExcessiveStackDepth.ts ===
410
// Repro from #43493
511

0 commit comments

Comments
 (0)