Skip to content

Commit 3d52392

Browse files
Logarithmish baseline counts (#58212)
1 parent bc86414 commit 3d52392

File tree

147 files changed

+459
-602
lines changed

Some content is hidden

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

147 files changed

+459
-602
lines changed

src/harness/harnessIO.ts

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -786,21 +786,27 @@ export namespace Compiler {
786786
const postPerformanceValues = getPerformanceBaselineValues();
787787

788788
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)) {
789+
const perfStats: [name: string, reportThreshold: number, beforeValue: number, afterValue: number][] = [];
790+
perfStats.push(["Strict subtype cache", 1000, prePerformanceValues.strictSubtype, postPerformanceValues.strictSubtype]);
791+
perfStats.push(["Subtype cache", 1000, prePerformanceValues.subtype, postPerformanceValues.subtype]);
792+
perfStats.push(["Identity cache", 1000, prePerformanceValues.identity, postPerformanceValues.identity]);
793+
perfStats.push(["Assignability cache", 1000, prePerformanceValues.assignability, postPerformanceValues.assignability]);
794+
perfStats.push(["Type Count", 1000, prePerformanceValues.typeCount, postPerformanceValues.typeCount]);
795+
perfStats.push(["Instantiation count", 1500, prePerformanceValues.instantiation, postPerformanceValues.instantiation]);
796+
perfStats.push(["Symbol count", 45000, prePerformanceValues.symbol, postPerformanceValues.symbol]);
797+
798+
if (perfStats.some(([, threshold, , postValue]) => postValue >= threshold)) {
799799
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})`);
800+
for (const [name, threshold, preValue, postValue] of perfStats) {
801+
if (postValue >= threshold) {
802+
const preString = valueToString(preValue);
803+
const postString = valueToString(postValue);
804+
if (preString === postString) {
805+
perfLines.push(`${name}: ${preString}`);
806+
}
807+
else {
808+
perfLines.push(`${name}: ${preString} -> ${postString}`);
809+
}
804810
}
805811
}
806812
perfLines.push("");
@@ -809,10 +815,24 @@ export namespace Compiler {
809815
}
810816

811817
return result ? (`//// [${header}] ////\r\n\r\n${perfLines.join("\n")}${result}`) : null; // eslint-disable-line no-null/no-null
818+
819+
function valueToString(value: number) {
820+
return roundToHumanLogarithm(value).toLocaleString("en-US");
821+
}
812822
}
813823

814-
function valueToString(value: number, rounding: number) {
815-
return (Math.round(value / rounding) * rounding).toLocaleString("en-US");
824+
/**
825+
* Rounds to a number like 10, 25, 50, 100, 250, 500, 1000, etc
826+
*/
827+
function roundToHumanLogarithm(n: number) {
828+
if (n < 10) return 0;
829+
const powerOfTen = Math.floor(Math.log10(n));
830+
const basePowerOfTen = Math.pow(10, powerOfTen);
831+
const multipliers = [1, 2.5, 5, 10];
832+
const closestMultiplier = multipliers.reduce((prev, curr) => {
833+
return Math.abs(curr * basePowerOfTen - n) < Math.abs(prev * basePowerOfTen - n) ? curr : prev;
834+
});
835+
return closestMultiplier * basePowerOfTen;
816836
}
817837

818838
function getPerformanceBaselineValues() {

tests/baselines/reference/awaitedType.types

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//// [tests/cases/compiler/awaitedType.ts] ////
22

33
=== 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)
4+
Instantiation count: 25,000
85

96
=== awaitedType.ts ===
107
type T1 = Awaited<number>;

tests/baselines/reference/awaitedTypeStrictNull.types

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

33
=== 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)
4+
Instantiation count: 25,000
95

106
=== awaitedTypeStrictNull.ts ===
117
type T1 = Awaited<number>;

tests/baselines/reference/callsOnComplexSignatures.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
98

109
=== callsOnComplexSignatures.tsx ===
1110
/// <reference path="react16.d.ts" />

tests/baselines/reference/checkJsxChildrenCanBeTupleType.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
88

99
=== checkJsxChildrenCanBeTupleType.tsx ===
1010
/// <reference path="react16.d.ts" />

tests/baselines/reference/checkJsxChildrenProperty16.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
88

99
=== checkJsxChildrenProperty16.tsx ===
1010
/// <reference path="react16.d.ts" />

tests/baselines/reference/checkJsxUnionSFXContextualTypeInferredCorrectly.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
88

99
=== checkJsxUnionSFXContextualTypeInferredCorrectly.tsx ===
1010
/// <reference path="react16.d.ts" />

tests/baselines/reference/circularBaseConstraint.types

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//// [tests/cases/compiler/circularBaseConstraint.ts] ////
22

33
=== 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)
4+
Instantiation count: 2,500
85

96
=== circularBaseConstraint.ts ===
107
// Repro from #54610

tests/baselines/reference/circularlySimplifyingConditionalTypesNoCrash.types

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//// [tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts] ////
22

33
=== 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)
4+
Instantiation count: 2,500
85

96
=== circularlySimplifyingConditionalTypesNoCrash.ts ===
107
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

tests/baselines/reference/complexRecursiveCollections.types

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

33
=== 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)
4+
Assignability cache: 10,000
5+
Type Count: 50,000
6+
Instantiation count: 250,000
7+
Symbol count: 100,000
98

109
=== complex.ts ===
1110
interface Ara<T> { t: T }

tests/baselines/reference/conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.types

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

33
=== Performance Stats ===
4-
Strict subtype cache: 2,000 / 2,000 (nearest 100)
5-
Assignability cache: 16,000 / 16,000 (nearest 100)
6-
Type Count: 14,200 / 14,200 (nearest 100)
7-
Instantiation count: 84,000 / 84,000 (nearest 500)
8-
Symbol count: 33,500 / 33,500 (nearest 500)
4+
Strict subtype cache: 2,500
5+
Assignability cache: 10,000
6+
Type Count: 10,000
7+
Instantiation count: 100,000
98

109
=== conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.ts ===
1110
type BigUnion =

tests/baselines/reference/conditionalTypeDoesntSpinForever.types

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//// [tests/cases/compiler/conditionalTypeDoesntSpinForever.ts] ////
22

33
=== 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)
4+
Type Count: 1,000
5+
Instantiation count: 2,500 -> 5,000
86

97
=== conditionalTypeDoesntSpinForever.ts ===
108
// A *self-contained* demonstration of the problem follows...

tests/baselines/reference/conditionalTypeVarianceBigArrayConstraintsPerformance.types

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

33
=== 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)
4+
Assignability cache: 1,000
5+
Type Count: 5,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
88

99
=== conditionalTypeVarianceBigArrayConstraintsPerformance.ts ===
1010
/// <reference path="react16.d.ts" />

tests/baselines/reference/conditionalTypes1.types

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//// [tests/cases/conformance/types/conditional/conditionalTypes1.ts] ////
22

33
=== 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)
4+
Instantiation count: 1,000
85

96
=== conditionalTypes1.ts ===
107
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"

tests/baselines/reference/contextuallyTypedJsxChildren.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
88

99
=== contextuallyTypedJsxChildren.tsx ===
1010
/// <reference path="react16.d.ts" />

tests/baselines/reference/controlFlowOptionalChain3.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 100,000
7+
Symbol count: 50,000
88

99
=== controlFlowOptionalChain3.tsx ===
1010
/// <reference path="react16.d.ts" />

tests/baselines/reference/correlatedUnions.types

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//// [tests/cases/compiler/correlatedUnions.ts] ////
22

33
=== 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)
4+
Type Count: 1,000
85

96
=== correlatedUnions.ts ===
107
// Various repros from #30581

tests/baselines/reference/declarationEmitRecursiveConditionalAliasPreserved.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 50,000
7+
Symbol count: 50,000
88

99
=== input.d.ts ===
1010
type _BuildPowersOf2LengthArrays<

tests/baselines/reference/declarationsAndAssignments.types

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//// [tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts] ////
22

33
=== 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)
4+
Type Count: 500 -> 1,000
85

96
=== declarationsAndAssignments.ts ===
107
function f0() {

tests/baselines/reference/deepComparisons.types

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//// [tests/cases/compiler/deepComparisons.ts] ////
22

33
=== Performance Stats ===
4-
Assignability cache: 300 / 300 (nearest 100)
5-
Type Count: 2,000 / 2,000 (nearest 100)
6-
Instantiation count: 3,500 / 3,500 (nearest 500)
7-
Symbol count: 26,500 / 27,000 (nearest 500)
4+
Type Count: 2,500
5+
Instantiation count: 2,500
86

97
=== deepComparisons.ts ===
108
function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>() {

tests/baselines/reference/deeplyNestedMappedTypes.types

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//// [tests/cases/compiler/deeplyNestedMappedTypes.ts] ////
22

33
=== 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)
4+
Type Count: 1,000
5+
Instantiation count: 10,000
86

97
=== deeplyNestedMappedTypes.ts ===
108
// Simplified repro from #55535

tests/baselines/reference/dependentDestructuredVariables.types

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

33
=== 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)
4+
Type Count: 2,500
5+
Instantiation count: 1,000
86

97
=== dependentDestructuredVariables.ts ===
108
type Action =

tests/baselines/reference/divideAndConquerIntersections.types

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//// [tests/cases/compiler/divideAndConquerIntersections.ts] ////
22

33
=== Performance Stats ===
4-
Assignability cache: 100 / 100 (nearest 100)
5-
Type Count: 2,800 / 2,900 (nearest 100)
6-
Instantiation count: 7,500 / 7,500 (nearest 500)
7-
Symbol count: 26,000 / 26,000 (nearest 500)
4+
Type Count: 2,500
5+
Instantiation count: 10,000
86

97
=== divideAndConquerIntersections.ts ===
108
type QQ<T extends string[]> =

tests/baselines/reference/duplicateNumericIndexers.types

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

33
=== 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)
4+
Assignability cache: 2,500
5+
Type Count: 10,000
6+
Instantiation count: 2,500
87

98
=== duplicateNumericIndexers.ts ===
109
// it is an error to have duplicate index signatures of the same kind in a type

tests/baselines/reference/enumLiteralsSubtypeReduction.types

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//// [tests/cases/compiler/enumLiteralsSubtypeReduction.ts] ////
22

33
=== Performance Stats ===
4-
Type Count: 3,200 / 3,200 (nearest 100)
5-
Symbol count: 26,500 / 26,500 (nearest 500)
4+
Type Count: 2,500
65

76
=== enumLiteralsSubtypeReduction.ts ===
87
enum E {

0 commit comments

Comments
 (0)