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 }

0 commit comments

Comments
 (0)