New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse computed type of condition expressions #49881
Merged
weswigham
merged 1 commit into
microsoft:main
from
JoostK:perf/recursive-function-checks
Aug 27, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/uncalledFunctionChecksInConditionalPerf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//// [uncalledFunctionChecksInConditionalPerf.ts] | ||
declare const b: boolean; | ||
|
||
((((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b); | ||
|
||
|
||
//// [uncalledFunctionChecksInConditionalPerf.js] | ||
((((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b); |
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/uncalledFunctionChecksInConditionalPerf.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
=== tests/cases/compiler/uncalledFunctionChecksInConditionalPerf.ts === | ||
declare const b: boolean; | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
|
||
((((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b); | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
>b : Symbol(b, Decl(uncalledFunctionChecksInConditionalPerf.ts, 0, 13)) | ||
|
83 changes: 83 additions & 0 deletions
83
tests/baselines/reference/uncalledFunctionChecksInConditionalPerf.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
=== tests/cases/compiler/uncalledFunctionChecksInConditionalPerf.ts === | ||
declare const b: boolean; | ||
>b : boolean | ||
|
||
((((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b); | ||
>((((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((((b) && b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((((b) && b) && b) && b) && b) && b) && b) && b) : boolean | ||
>(((((((b) && b) && b) && b) && b) && b) && b) && b : boolean | ||
>(((((((b) && b) && b) && b) && b) && b) && b) : boolean | ||
>((((((b) && b) && b) && b) && b) && b) && b : boolean | ||
>((((((b) && b) && b) && b) && b) && b) : boolean | ||
>(((((b) && b) && b) && b) && b) && b : boolean | ||
>(((((b) && b) && b) && b) && b) : boolean | ||
>((((b) && b) && b) && b) && b : boolean | ||
>((((b) && b) && b) && b) : boolean | ||
>(((b) && b) && b) && b : boolean | ||
>(((b) && b) && b) : boolean | ||
>((b) && b) && b : boolean | ||
>((b) && b) : boolean | ||
>(b) && b : boolean | ||
>(b) : boolean | ||
>b : boolean | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
>b : true | ||
|
5 changes: 5 additions & 0 deletions
5
tests/cases/compiler/uncalledFunctionChecksInConditionalPerf.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// @strictNullChecks: true | ||
|
||
declare const b: boolean; | ||
|
||
((((((((((((((((((((((((((b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b) && b); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we have a better way of capturing this kind of test, where the thing we're interested in is the execution time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically we don't - but tests do have a timeout (around 50s), so if you make sure they're large enough to hit the timeout before your change, they're a decent test; they won't capture tiny pretty regressions, but will prevent big ones. We have other tests in this vein.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then. @JoostK can you make this example much much bigger, so that the test would timeout without the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add 4 additional binary ops, which would have brought check times up by a factor of 16 (easily pushing it beyond the 50s threshold)