Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@justinfagnani
Copy link
Collaborator

@justinfagnani justinfagnani commented Jul 19, 2023

Fixes #4018

Builds on #3980

Implements a BYOTS pattern for the analyzer. This PR does not update TypeScript yet, but I think we should update it to 5.0 as a follow up.

I implemented this fairly mechanically, bottom-up, adding a typescript arg to functions that needed it, and re-using the analyzer argument if there already was one. The end result might be a little inconsistent, but functions generally take only what they need. I think stylistically it might be nice to most the analyzer argument first, as would be done with curry-compatible style (put the varying arguments last).

@changeset-bot
Copy link

changeset-bot bot commented Jul 19, 2023

🦋 Changeset detected

Latest commit: 63bc673

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@lit-labs/analyzer Minor
@lit-labs/cli Patch
@lit-labs/gen-manifest Patch
@lit-labs/gen-utils Patch
@lit-labs/gen-wrapper-angular Patch
@lit-labs/gen-wrapper-react Patch
@lit-labs/gen-wrapper-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@justinfagnani justinfagnani changed the title Require a TypeScript object to construct an Analyzer [labs/analyzer] Require a TypeScript object to construct an Analyzer Jul 19, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 19, 2023

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -9% - +7% (-2.24ms - +1.79ms)
    this-change vs tip-of-tree

render

  • lit-element-list: 77.57ms - 81.80ms
  • lit-html-kitchen-sink: unsure 🔍 -9% - +6% (-3.21ms - +2.17ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +3% (-0.52ms - +0.31ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -3% - +3% (-1.71ms - +1.52ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -3% - +1% (-1.40ms - +0.65ms)
    this-change vs tip-of-tree

update

  • lit-element-list: 885.12ms - 902.16ms
  • lit-html-kitchen-sink: unsure 🔍 -4% - +5% (-3.63ms - +4.54ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -0% - +5% (-0.51ms - +15.55ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -1% - +3% (-0.63ms - +3.93ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -1% - +1% (-7.06ms - +12.07ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: 828.61ms - 841.13ms
  • reactive-element-list: unsure 🔍 -2% - +0% (-13.32ms - +3.28ms)
    this-change vs tip-of-tree

Results

lit-element-list

render

VersionAvg timevs
77.57ms - 81.80ms-

update

VersionAvg timevs
885.12ms - 902.16ms-

update-reflect

VersionAvg timevs
828.61ms - 841.13ms-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
33.44ms - 36.78ms-unsure 🔍
-9% - +6%
-3.21ms - +2.17ms
unsure 🔍
-6% - +9%
-2.19ms - +2.95ms
tip-of-tree
tip-of-tree
33.52ms - 37.73msunsure 🔍
-6% - +9%
-2.17ms - +3.21ms
-unsure 🔍
-6% - +11%
-1.97ms - +3.77ms
previous-release
previous-release
32.78ms - 36.68msunsure 🔍
-8% - +6%
-2.95ms - +2.19ms
unsure 🔍
-10% - +5%
-3.77ms - +1.97ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
87.89ms - 93.69ms-unsure 🔍
-4% - +5%
-3.63ms - +4.54ms
unsure 🔍
-5% - +5%
-4.19ms - +4.88ms
tip-of-tree
tip-of-tree
87.46ms - 93.22msunsure 🔍
-5% - +4%
-4.54ms - +3.63ms
-unsure 🔍
-5% - +5%
-4.63ms - +4.41ms
previous-release
previous-release
86.96ms - 93.93msunsure 🔍
-5% - +5%
-4.88ms - +4.19ms
unsure 🔍
-5% - +5%
-4.41ms - +4.63ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
24.34ms - 26.46ms-unsure 🔍
-9% - +7%
-2.24ms - +1.79ms
unsure 🔍
-13% - +2%
-3.60ms - +0.67ms
tip-of-tree
tip-of-tree
23.91ms - 27.34msunsure 🔍
-7% - +9%
-1.79ms - +2.24ms
-unsure 🔍
-14% - +5%
-3.76ms - +1.28ms
previous-release
previous-release
25.01ms - 28.71msunsure 🔍
-3% - +14%
-0.67ms - +3.60ms
unsure 🔍
-5% - +15%
-1.28ms - +3.76ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
11.14ms - 11.79ms-unsure 🔍
-4% - +3%
-0.52ms - +0.31ms
unsure 🔍
-5% - +4%
-0.59ms - +0.43ms
tip-of-tree
tip-of-tree
11.31ms - 11.83msunsure 🔍
-3% - +5%
-0.31ms - +0.52ms
-unsure 🔍
-4% - +4%
-0.44ms - +0.50ms
previous-release
previous-release
11.15ms - 11.94msunsure 🔍
-4% - +5%
-0.43ms - +0.59ms
unsure 🔍
-4% - +4%
-0.50ms - +0.44ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
333.33ms - 346.05ms-unsure 🔍
-0% - +5%
-0.51ms - +15.55ms
unsure 🔍
-4% - +2%
-13.74ms - +5.97ms
tip-of-tree
tip-of-tree
327.26ms - 337.08msunsure 🔍
-5% - +0%
-15.55ms - +0.51ms
-faster ✔
1% - 6%
2.42ms - 20.40ms
previous-release
previous-release
336.04ms - 351.11msunsure 🔍
-2% - +4%
-5.97ms - +13.74ms
slower ❌
1% - 6%
2.42ms - 20.40ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
58.08ms - 60.38ms-unsure 🔍
-3% - +3%
-1.71ms - +1.52ms
slower ❌
1% - 6%
0.32ms - 3.32ms
tip-of-tree
tip-of-tree
58.19ms - 60.46msunsure 🔍
-3% - +3%
-1.52ms - +1.71ms
-slower ❌
1% - 6%
0.42ms - 3.40ms
previous-release
previous-release
56.45ms - 58.38msfaster ✔
1% - 6%
0.32ms - 3.32ms
faster ✔
1% - 6%
0.42ms - 3.40ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
126.63ms - 129.80ms-unsure 🔍
-1% - +3%
-0.63ms - +3.93ms
unsure 🔍
-1% - +3%
-1.63ms - +3.37ms
tip-of-tree
tip-of-tree
124.93ms - 128.20msunsure 🔍
-3% - +0%
-3.93ms - +0.63ms
-unsure 🔍
-3% - +1%
-3.31ms - +1.75ms
previous-release
previous-release
125.41ms - 129.28msunsure 🔍
-3% - +1%
-3.37ms - +1.63ms
unsure 🔍
-1% - +3%
-1.75ms - +3.31ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
50.07ms - 51.52ms-unsure 🔍
-3% - +1%
-1.40ms - +0.65ms
unsure 🔍
-1% - +3%
-0.70ms - +1.39ms
tip-of-tree
tip-of-tree
50.44ms - 51.90msunsure 🔍
-1% - +3%
-0.65ms - +1.40ms
-unsure 🔍
-1% - +4%
-0.34ms - +1.77ms
previous-release
previous-release
49.69ms - 51.21msunsure 🔍
-3% - +1%
-1.39ms - +0.70ms
unsure 🔍
-3% - +1%
-1.77ms - +0.34ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
888.15ms - 901.89ms-unsure 🔍
-1% - +1%
-7.06ms - +12.07ms
unsure 🔍
-1% - +2%
-4.83ms - +14.24ms
tip-of-tree
tip-of-tree
885.86ms - 899.18msunsure 🔍
-1% - +1%
-12.07ms - +7.06ms
-unsure 🔍
-1% - +1%
-7.19ms - +11.59ms
previous-release
previous-release
883.70ms - 896.93msunsure 🔍
-2% - +1%
-14.24ms - +4.83ms
unsure 🔍
-1% - +1%
-11.59ms - +7.19ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
859.92ms - 871.16ms-unsure 🔍
-2% - +0%
-13.32ms - +3.28ms
unsure 🔍
-1% - +1%
-9.10ms - +6.71ms
tip-of-tree
tip-of-tree
864.46ms - 876.67msunsure 🔍
-0% - +2%
-3.28ms - +13.32ms
-unsure 🔍
-1% - +1%
-4.44ms - +12.09ms
previous-release
previous-release
861.17ms - 872.30msunsure 🔍
-1% - +1%
-6.71ms - +9.10ms
unsure 🔍
-1% - +1%
-12.09ms - +4.44ms
-

tachometer-reporter-action v2 for Benchmarks

Base automatically changed from analyzer-files to main July 19, 2023 16:24
path: this.path,
typescript: this.typescript,
getProgram: this._getProgram,
} = init);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this syntax any better? a sequence of assignments seems more legible and more likely to be optimized by VMs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In size constrained libraries it removes a dereference per property, and I've started to like the look of the pattern. It's also nice for code-completion when you add a new option to the init interface.

*/
const parseType = (typeString: string): ts.TypeNode | undefined => {
// TODO (justinfagnani): This would probably be a bit cleaner as an instance
// method on Analyzer now.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will never be an easier time to make breaking changes than now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't be a breaking change, and would add public API, so I wanted to be conservative.

There are a lot of potential cleanups I saw while in here, I also needed to limit the changes to just the relevant ones to keep things reviewable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[labs/analyzer] Support for BYO TypeScript version

2 participants